Commit b32b42f6 authored by Rahadi Jalu's avatar Rahadi Jalu

Current Changes

parent 2ee4e7a9
Pipeline #145 canceled with stages
......@@ -53,18 +53,6 @@ Secara umum, pengembangan aplikasi lebih lanjut dapat dilakukan dengan langkah-l
7. Untuk melakukan run project, tekan tombol panah hijau di bagian atas dari Android Studio.
> Note: Penggunaan emulator mungkin dapat mengakibatkan aplikasi berjalan lambat. Oleh karena itu, disarankan untuk menggunakan device selama memungkinkan.
## Panduan & Dokumentasi
Berikut adalah *table of content* dari panduan yang tersedia:
1. Instalasi aplikasi
- Menggunakan APK
- Run project pada Android Studio
2. Penggunaan aplikasi
- Konfigurasi Server
- User Interface pemutakhiran
- Keterkaitan Kuesioner
## Credits
Banyak pihak yang telah dilibatkan dalam melakukan pengembangan aplikasi ini. Oleh karena itu, pengembang mengucapkan terima kasih kepada:
......
......@@ -313,7 +313,7 @@ public class CapiInstanceActivity extends AppCompatActivity
HashMap<String, String> informations = new HashMap<>();
File file = new File(instance.getInstanceFilePath());
InstanceValues values = XmlUtils.getInstanceValues(instance.getInstanceUuid(), file, labels);
InstanceValues values = XmlUtils.getInstanceValues(instance.getInstanceUuid(), file, labels, InstanceValues.STATE_NEUTRAL);
Set<String> parsedXpaths = values.getXPaths();
for(String parsed : parsedXpaths) {
if(parsed.equals(titleSelected)) {
......
......@@ -40,26 +40,12 @@ public class HierarchyAdapter extends RecyclerView.Adapter<HierarchyAdapter.View
@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));
}
......
......@@ -60,6 +60,9 @@ public class NodeViewFactory extends BaseNodeViewFactory {
case ModeTreeNode.QUEUED:
imageStatus.setImageResource(R.drawable.ic_download);
break;
case ModeTreeNode.FAILED:
imageStatus.setImageResource(R.drawable.ic_cancel);
break;
}
} else {
secondaryText.setVisibility(View.GONE);
......
......@@ -29,7 +29,7 @@ import id.ac.stis.capi.odk.dto.Form;
public class InstancePreferenceFragment extends BasePreferenceFragment {
private PreferencesManager manager;
private ListPreference viewModePref, titlePref, constraintPref;
private ListPreference viewModePref, titlePref, constraintPref, filterPref;
private MultiSelectListPreference subtitlePref;
private String formId;
private FormLabels formLabels;
......@@ -53,7 +53,8 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
List<Form> forms = formsDao.getFormsFromCursor(formsDao.getFormsCursorForFormId(formId));
File file = new File(forms.get(0).getFormFilePath());
List<String> xPaths = XmlUtils.getInstanceXPathList(file);
List<String> xPaths = XmlUtils.getInstanceXPathList(file, false);
formLabels = XmlUtils.getFormLabels(formId, file, xPaths);
entries = new LinkedList<>();
......@@ -87,11 +88,14 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
}
if (titlePref != null) {
entries.addFirst("Default Title");
entryValues.addFirst(PreferencesAPI.TITLE_DEFAULT);
LinkedList<String> titleEntries = new LinkedList<>(entries);
titleEntries.addFirst("Default Title");
LinkedList<String> titleEntryValues = new LinkedList<>(entryValues);
titleEntryValues.addFirst(PreferencesAPI.TITLE_DEFAULT);
titlePref.setEntries(entries.toArray(new CharSequence[entries.size()]));
titlePref.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()]));
titlePref.setEntries(titleEntries.toArray(new CharSequence[titleEntries.size()]));
titlePref.setEntryValues(titleEntryValues.toArray(new CharSequence[titleEntryValues.size()]));
}
String value = (String) manager.getByFormId(PreferencesAPI.KEY_VIEW_MODE, formId);
......@@ -141,6 +145,22 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
break;
}
}
filterPref = (ListPreference) findPreference(PreferencesAPI.KEY_FILTER);
if (filterPref != null) {
LinkedList<String> filterEntries = new LinkedList<>(entries);
filterEntries.addFirst("None");
LinkedList<String> filterEntryValues = new LinkedList<>(entryValues);
filterEntryValues.addFirst(PreferencesAPI.FILTER_NONE);
filterPref.setEntries(filterEntries.toArray(new CharSequence[filterEntries.size()]));
filterPref.setEntryValues(filterEntryValues.toArray(new CharSequence[filterEntryValues.size()]));
String val = (String) manager.getByFormId(PreferencesAPI.KEY_FILTER, formId);
setSelectSummary(filterPref, val);
filterPref.setValue(val);
}
}
private void setListeners() {
......@@ -228,6 +248,19 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
}
});
}
if (filterPref != null) {
setSelectSummary(filterPref, (String) manager.getByFormId(PreferencesAPI.KEY_FILTER, formId));
filterPref.setKey(manager.getKey(filterPref.getKey(), formId));
filterPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
setSelectSummary(filterPref, newValue.toString());
return true;
}
});
}
}
private String getViewModeValue(String entryValue) {
......@@ -253,8 +286,13 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
}
private void setSelectSummary(ListPreference preference, String entryValue) {
if(entryValue.isEmpty() || entryValue.trim().length() == 0 || entryValue.equals(PreferencesAPI.TITLE_DEFAULT)) {
if (entryValue == null
|| entryValue.isEmpty()
|| entryValue.trim().length() == 0
|| entryValue.equals(PreferencesAPI.TITLE_DEFAULT)) {
preference.setSummary("Default Title");
} else if (entryValue.equals(PreferencesAPI.FILTER_NONE)) {
preference.setSummary("None");
} else {
preference.setSummary(formLabels.getFormLabel(entryValue));
}
......@@ -263,7 +301,7 @@ public class InstancePreferenceFragment extends BasePreferenceFragment {
private void setMultiSelectSummary(MultiSelectListPreference preference, HashSet<String> set) {
boolean first = true;
if(!set.isEmpty()) {
if (!set.isEmpty()) {
StringBuilder values = new StringBuilder();
for (String v : set) {
if (!first) {
......
......@@ -11,14 +11,23 @@ import java.util.Set;
*/
public class InstanceValues implements Serializable {
// TODO: parsing instance value dobel ning instance karo group activity
public static int STATE_NEUTRAL = 0;
public static int STATE_ACTIVE = 1;
public static int STATE_COMPLETED = 2;
private String instanceId;
private String formId;
private int state;
private Map<String, String> instanceValue;
public InstanceValues(String instanceId, String formId, Map<String, String> instanceValue) {
public InstanceValues(String instanceId, String formId, Map<String, String> instanceValue,
int state) {
this.instanceId = instanceId;
this.formId = formId;
this.instanceValue = instanceValue;
this.state = state;
}
public InstanceValues putInstanceValue(String xPath, String value) {
......@@ -46,4 +55,7 @@ public class InstanceValues implements Serializable {
return instanceValue.get(xPath);
}
public int getState() {
return state;
}
}
......@@ -11,6 +11,7 @@ public class ModeTreeNode extends TreeNode {
public static final int DOWNLOADED = 0;
public static final int QUEUED = 1;
public static final int FAILED = 2;
private int mode;
private String valueId;
......
......@@ -9,10 +9,6 @@ import java.util.HashSet;
* Company: Politeknik Statistika STIS
*/
public class PreferencesAPI {
public static final String KEY_CATEGORY_APPEARANCE = "appearance_category";
public static final String KEY_RESPONSE_APPEARANCE = "response_category";
public static final String KEY_CONSTRAINT_APPEARANCE = "constraint_category";
public static final String KEY_VIEW_MODE = "view_mode";
public static final String KEY_TITLE = "title";
......@@ -20,8 +16,12 @@ public class PreferencesAPI {
public static final String KEY_CONSTRAINT = "constraint";
public static final String KEY_FILTER = "filter";
public static final String TITLE_DEFAULT = "default";
public static final String FILTER_NONE = "none";
public static final String VIEW_MODE_ROSTER = "roster";
public static final String VIEW_MODE_CARDS = "cards";
......
......@@ -6,6 +6,7 @@ import android.graphics.PorterDuff;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
......@@ -23,10 +24,12 @@ import id.ac.stis.capi.lessthink.listeners.OnFooterNavigationListener;
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public class TableFooterView extends RelativeLayout implements View.OnClickListener {
public class TableFooterView extends LinearLayout implements View.OnClickListener {
private View shadowView;
private ImageView addButton;
private TextView currPage;
private RelativeLayout container;
private LinearLayout pageIndicator, navigationWrapper;
private int textSize, componentColor, footerColor, currentPage, pageCount;
private OnFooterNavigationListener onFooterNavigationListener;
......@@ -35,6 +38,8 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
public TableFooterView(Context context, AttributeSet attrs) {
super(context, attrs);
setOrientation(VERTICAL);
this.textSize = 12;
this.componentColor = ContextCompat.getColor(getContext(), R.color.white);
this.footerColor = ContextCompat.getColor(getContext(), R.color.accent);
......@@ -55,10 +60,25 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
a.recycle();
}
setBackgroundColor(getFooterColor());
this.shadowView = LayoutInflater.from(getContext()).inflate(R.layout.toolbar_action_bar_shadow_inverted, null, false);
LinearLayout.LayoutParams shadowViewParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
shadowView.setLayoutParams(shadowViewParams);
addView(shadowView);
this.container = new RelativeLayout(getContext());
LinearLayout.LayoutParams containerParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
container.setLayoutParams(containerParams);
addView(container);
container.setBackgroundColor(getFooterColor());
this.pageIndicator = new LinearLayout(getContext());
RelativeLayout.LayoutParams pageIndicatorParams = new LayoutParams(
RelativeLayout.LayoutParams pageIndicatorParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
pageIndicatorParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
......@@ -71,7 +91,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
pageIndicator.setPadding(15, 15, 15, 15);
pageIndicator.setOrientation(LinearLayout.VERTICAL);
addView(pageIndicator);
container.addView(pageIndicator);
TextView page = new TextView(getContext());
page.setTextColor(getComponentColor());
......@@ -90,7 +110,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
pageIndicator.addView(currPage);
this.navigationWrapper = new LinearLayout(getContext());
RelativeLayout.LayoutParams navigationWrapperParams = new LayoutParams(
RelativeLayout.LayoutParams navigationWrapperParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
navigationWrapperParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
......@@ -98,7 +118,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
navigationWrapper.setLayoutParams(navigationWrapperParams);
addView(navigationWrapper);
container.addView(navigationWrapper);
int sizeForButtons = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
40, getResources().getDisplayMetrics()));
......@@ -148,7 +168,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
this.addButton = new ImageView(getContext(), null, 0);
addButton.setId(R.id.footer_view_add_button);
RelativeLayout.LayoutParams addButtonParams = new LayoutParams(sizeForButtons, sizeForButtons);
RelativeLayout.LayoutParams addButtonParams = new RelativeLayout.LayoutParams(sizeForButtons, sizeForButtons);
addButtonParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
addButtonParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
......@@ -164,7 +184,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
addButton.setOnClickListener(this);
addView(addButton);
container.addView(addButton);
}
public void setPageCountInfo(int pageCount) {
......
......@@ -17,7 +17,6 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
import id.ac.stis.capi.R;
......@@ -85,6 +84,14 @@ public class TableHeaderView extends HorizontalScrollView {
header.setLayoutParams(headerParams);
this.handler = new RelativeLayout(getContext());
RelativeLayout.LayoutParams handlerParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
handlerParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
handler.setLayoutParams(handlerParams);
addView(container);
}
......@@ -135,6 +142,10 @@ public class TableHeaderView extends HorizontalScrollView {
public void setColumns(FormLabels columns) {
this.columns = columns;
header.removeAllViews();
handler.removeAllViews();
container.removeAllViews();
Set<String> columnsKeySet = columns.getXPaths();
for (String columnsKey : columnsKeySet) {
TextView col = new TextView(getContext());
......@@ -158,14 +169,6 @@ public class TableHeaderView extends HorizontalScrollView {
container.addView(header);
this.handler = new RelativeLayout(getContext());
RelativeLayout.LayoutParams handlerParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
handlerParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
handler.setLayoutParams(handlerParams);
ArrayList<View> headerViews = new ArrayList<>();
header.findViewsWithText(headerViews, "column", FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
for (View headerView : headerViews) {
......
......@@ -16,7 +16,6 @@ import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import id.ac.stis.capi.R;
......@@ -38,7 +37,8 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
private LinearLayout row;
private List<InstanceValues> rows;
private RelativeLayout separator, container;
private int headerViewRef, footerViewRef, rowPadding, textSize, rowCount, pageCount, currentPage;
private int headerViewRef, footerViewRef, rowPadding, textSize, rowCount, pageCount,
currentPage;
private TableHeaderView headerView;
private TableFooterView footerView;
private OnClickListener onClickListener;
......@@ -54,10 +54,14 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TableRowView,
0, 0);
try {
setHeaderViewRef(a.getResourceId(R.styleable.TableRowView_tableHeaderView, getHeaderViewRef()));
setFooterViewRef(a.getResourceId(R.styleable.TableRowView_tableFooterView, getFooterViewRef()));
setRowPadding(a.getDimensionPixelSize(R.styleable.TableRowView_rowPadding, getRowPadding()));
setTextSize(a.getDimensionPixelSize(R.styleable.TableRowView_rowTextSize, getTextSize()));
setHeaderViewRef(
a.getResourceId(R.styleable.TableRowView_tableHeaderView, getHeaderViewRef()));
setFooterViewRef(
a.getResourceId(R.styleable.TableRowView_tableFooterView, getFooterViewRef()));
setRowPadding(
a.getDimensionPixelSize(R.styleable.TableRowView_rowPadding, getRowPadding()));
setTextSize(
a.getDimensionPixelSize(R.styleable.TableRowView_rowTextSize, getTextSize()));
} finally {
a.recycle();
}
......@@ -112,9 +116,9 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
return currentPage;
}
public void initView(List<InstanceValues> rows) {
this.rows = rows;
public void initView() {
this.currentPage = 1;
this.rows = new ArrayList<>();
if (headerViewRef != 0) {
headerView = getRootView().findViewById(headerViewRef);
......@@ -199,11 +203,12 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
row.removeAllViews();
int rowHeight = 0;
int availableHeight = container.getHeight();
int availableHeight =
container.getHeight() != 0 ? container.getHeight() : measureViewHeight(container);
int currIdx = this.rowCount * page - this.rowCount;
int maxIdx;
if(this.rowCount != 0 && this.rowCount * page < rows.size()) {
if (this.rowCount != 0 && this.rowCount * page < rows.size()) {
maxIdx = this.rowCount * page;
} else {
maxIdx = rows.size();
......@@ -234,7 +239,8 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
LinearLayout.LayoutParams colParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
col.setPadding(18, 12 + getRowPadding(), 18, 12 + getRowPadding());
col.setPadding(18, 12 + getRowPadding(),
18, 12 + getRowPadding());
col.setEllipsize(TextUtils.TruncateAt.END);
col.setTextSize(TypedValue.COMPLEX_UNIT_SP, getTextSize());
col.setText(rowValue.getInstanceValue(rowValueKey));
......@@ -257,7 +263,8 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
if (currIdx % 2 == 0) {
column.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.white));
} else {
column.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.smoother_gray));
column.setBackgroundColor(
ContextCompat.getColor(getContext(), R.color.smoother_gray));
}
final FrameLayout columnWrapper = new FrameLayout(getContext());
......@@ -266,10 +273,12 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
columnWrapper.setLayoutParams(columnWrapperParams);
TypedValue outValue = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
getContext().getTheme()
.resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
columnWrapper.setTag(rowValue.getInstanceId());
columnWrapper.setForeground(ContextCompat.getDrawable(getContext(), outValue.resourceId));
columnWrapper
.setForeground(ContextCompat.getDrawable(getContext(), outValue.resourceId));
columnWrapper.addView(column);
......@@ -287,7 +296,7 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
// Timber.d("Row Height : %s, Available Height : %s", rowHeight, availableHeight);
}
if(rows.size() > 0) {
if (rows.size() > 0) {
this.rowCount = container.getHeight() / rowHeight;
this.currentPage = page;
......@@ -311,9 +320,9 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
ArrayList<View> cols = new ArrayList<>();
row.findViewsWithText(cols, "column_" + key, FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
View columnView = headerView.getColumnViewByTag(key);
for (View col : cols) {
TextView column = (TextView) col;
View columnView = headerView.getColumnViewByTag(key);
column.setWidth(measureViewWidth(columnView));
}
}
......@@ -328,7 +337,8 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
View col = headerView.getColumnViewByTag(separator.getTag().toString());
LinearLayout.LayoutParams colParams = (LinearLayout.LayoutParams) col.getLayoutParams();
RelativeLayout.LayoutParams handParams = (RelativeLayout.LayoutParams) separator.getLayoutParams();
RelativeLayout.LayoutParams handParams =
(RelativeLayout.LayoutParams) separator.getLayoutParams();
currLeftMargin += measureViewWidth(col) + currRightMargin;
currRightMargin = colParams.rightMargin;
......
......@@ -40,7 +40,8 @@ import id.ac.stis.capi.odk.utilities.ApplicationConstants;
* @author Mahendri Dwicahyo
*/
public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHolder> implements Filterable {
public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHolder>
implements Filterable {
private static final String FORMNAME = "formname";
private static final String FORM_ID_KEY = "formid";
private static final String FORM_VERSION_KEY = "formversion";
......@@ -51,10 +52,6 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
private ArrayList<HashMap<String, String>> dataSetOri;
private OnFormDeletedListener onFormDeletedListener;
public void setOnFormDeletedListener(OnFormDeletedListener onFormDeletedListener) {
this.onFormDeletedListener = onFormDeletedListener;
}
public CapiFormAdapter(Activity activity, Fragment fragment) {
this.context = activity;
dataSet = new ArrayList<>();
......@@ -62,6 +59,9 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
this.fragment = fragment;
}
public void setOnFormDeletedListener(OnFormDeletedListener onFormDeletedListener) {
this.onFormDeletedListener = onFormDeletedListener;
}
public void setDataSet(ArrayList<HashMap<String, String>> data) {
this.dataSet = data;
......@@ -71,7 +71,8 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.collectiva_item_form, null);
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.collectiva_item_form, null);
return new ViewHolder(v);
}
......@@ -81,7 +82,8 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
holder.title.setText(dataSet.get(FORMNAME));
holder.shortDescription.setText("Questionnaire Id : " + dataSet.get(FORM_ID_KEY));
if (dataSet.get(HAS_BEEN_DOWNLOADED) != null && dataSet.get(HAS_BEEN_DOWNLOADED).equals("true")) {
if (dataSet.get(HAS_BEEN_DOWNLOADED) != null &&
dataSet.get(HAS_BEEN_DOWNLOADED).equals("true")) {
holder.cardView.setCardElevation(2);
holder.imgPattern.setVisibility(View.VISIBLE);
holder.imgProject.setVisibility(View.GONE);
......@@ -108,10 +110,14 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
holder.imgPattern.setVisibility(View.GONE);
holder.imgProject.setVisibility(View.VISIBLE);
holder.dividerUnDownloaded.setVisibility(View.VISIBLE);
holder.cardView.setCardBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent));
if ((position == 0) || (position > 0 && this.dataSet.get(position - 1).get(HAS_BEEN_DOWNLOADED).equals("true")))
holder.cardView.setCardBackgroundColor(
ContextCompat.getColor(context, android.R.color.transparent));
if ((position == 0) || (position > 0 &&
this.dataSet.get(position - 1).get(HAS_BEEN_DOWNLOADED).equals("true"))) {
holder.divider.setVisibility(View.VISIBLE);
else holder.divider.setVisibility(View.GONE);
} else {
holder.divider.setVisibility(View.GONE);
}
holder.cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -122,9 +128,11 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
}
private void seeListRespons(int position) {
Intent intent;
String viewMode = (String) PreferencesManager.getInstance().getByFormId(PreferencesAPI.KEY_VIEW_MODE, dataSet.get(position).get(FORM_ID_KEY));
String viewMode = (String) PreferencesManager.getInstance()
.getByFormId(PreferencesAPI.KEY_VIEW_MODE, dataSet.get(position).get(FORM_ID_KEY));
if (viewMode.equalsIgnoreCase(PreferencesAPI.VIEW_MODE_ROSTER)) {
intent = new Intent(context, InstanceActivity.class);
} else {
......@@ -136,12 +144,14 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
intent.putExtra(FORM_ID_KEY, dataSet.get(position).get(FORM_ID_KEY));
intent.putExtra(FORMNAME, dataSet.get(position).get(FORMNAME));
context.startActivity(intent);
}
private void showOptionDelete(final int position) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(dataSet.get(position).get(FORMNAME));
builder.setItems(new String[]{"See List Response", "Open new Form", "Delete Form"}, new DialogInterface.OnClickListener() {
builder.setItems(new String[]{"See List Response", "Open new Form", "Delete Form"},
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
......@@ -166,21 +176,26 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
long itemIdPosition = -1;
if (formslist.moveToFirst()) {
do {
if (formslist.getString(formslist.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID)).equals(dataSet.get(position).get(FORM_ID_KEY))) {
itemIdPosition = formslist.getLong(formslist.getColumnIndex(FormsProviderAPI.FormsColumns._ID));
if (formslist.getString(
formslist.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID))
.equals(dataSet.get(position).get(FORM_ID_KEY))) {
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);
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, dataSet.get(position).get(FORMNAME));
intent.putExtra(ApplicationConstants.BundleKeys.FORM_MODE, ApplicationConstants.FormModes.EDIT_SAVED);
intent.putExtra(ApplicationConstants.BundleKeys.FORM_MODE,
ApplicationConstants.FormModes.EDIT_SAVED);
context.startActivity(intent);
} else {
//xxxseharusnya tidak terjadi, tidak mungkin itemIdposition < 1
......@@ -196,13 +211,17 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo
Long itemIdPosition = Long.valueOf("-1");
if (formslist.moveToFirst()) {
do {
if (formslist.getString(formslist.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID)).equals(formIdKey)) {
itemIdPosition = formslist.getLong(formslist.getColumnIndex(FormsProviderAPI.FormsColumns._ID));
if (formslist.getString(
formslist.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID))
.equals(formIdKey)) {
itemIdPosition = formslist
.getLong(formslist.getColumnIndex(FormsProviderAPI.FormsColumns._ID));
}
} while (formslist.moveToNext());
}
Uri deleteForm = Uri.withAppendedPath(FormsProviderAPI.FormsColumns.CONTENT_URI, itemIdPosition.toString());
Uri deleteForm = Uri.withAppendedPath(FormsProviderAPI.FormsColumns.CONTENT_URI,
itemIdPosition.toString());
cr.delete(deleteForm, null, null);
HashMap<String, String> deletedItems = dataSet.get(position);
......@@ -220,7 +239,8 @@ public class CapiFormAdapter extends RecyclerView.Adapter<CapiFormAdapter.ViewHo