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;
......
......@@ -79,6 +79,7 @@ public final class PreferenceKeys {
public static final String KEY_UPDATE_URL = "update_url";
public static final String KEY_UNIQUES = "unique_uuid";
public static final String KEY_LOGIN_STATUS = "login_status";
public static final String KEY_FILTER_URL = "filter_url";
private static HashMap<String, Object> getHashMap() {
......@@ -115,6 +116,7 @@ public final class PreferenceKeys {
hashMap.put(KEY_UPDATE_URL, Collect.getInstance().getString(R.string.odk_capi_update));
hashMap.put(KEY_UNIQUES, "");
hashMap.put(KEY_LOGIN_STATUS, false);
hashMap.put(KEY_FILTER_URL, Collect.getInstance().getString(R.string.odk_capi_submission_filter));
return hashMap;
}
......
/*
* Copyright (C) 2017 Nyoman Ribeka
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
......@@ -18,15 +18,7 @@ import android.content.ContentValues;
import android.database.Cursor;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.util.Log;
import id.ac.stis.capi.R;
import id.ac.stis.capi.odk.application.Collect;
import id.ac.stis.capi.odk.dao.InstancesDao;
import id.ac.stis.capi.odk.listeners.DiskSyncListener;
import id.ac.stis.capi.odk.preferences.PreferenceKeys;
import id.ac.stis.capi.odk.provider.FormsProviderAPI.FormsColumns;
import id.ac.stis.capi.odk.provider.InstanceProviderAPI;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
......@@ -41,6 +33,13 @@ import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import id.ac.stis.capi.R;
import id.ac.stis.capi.odk.application.Collect;
import id.ac.stis.capi.odk.dao.InstancesDao;
import id.ac.stis.capi.odk.listeners.DiskSyncListener;
import id.ac.stis.capi.odk.preferences.PreferenceKeys;
import id.ac.stis.capi.odk.provider.FormsProviderAPI.FormsColumns;
import id.ac.stis.capi.odk.provider.InstanceProviderAPI;
import timber.log.Timber;
import static id.ac.stis.capi.odk.provider.InstanceProviderAPI.InstanceColumns;
......@@ -53,10 +52,8 @@ import static id.ac.stis.capi.odk.provider.InstanceProviderAPI.LATEST_VERSION;
*/
public class InstanceSyncTask extends AsyncTask<Void, String, String> {
private final String TAG = getClass().getSimpleName();
private static int counter = 0;
private final String TAG = getClass().getSimpleName();
private String currentStatus;
private DiskSyncListener diskSyncListener;
......@@ -213,20 +210,24 @@ public class InstanceSyncTask extends AsyncTask<Void, String, String> {
private String getInstanceIdFromInstance(final String instancePath) {
String instanceUuid = null;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new File(instancePath));
Element element = document.getDocumentElement();
NodeList meta = element.getElementsByTagName("meta").item(0).getChildNodes();
for(int i =0;i<meta.getLength();i++){
NodeList meta = element.getElementsByTagNameNS("*", "meta")
.item(0).getChildNodes();
for (int i = 0; i < meta.getLength(); i++) {
Node item = meta.item(i);
if(item.getNodeName().trim().equals("instanceID")){
if (item.getLocalName().trim().equals("instanceID")) {
instanceUuid = item.getTextContent().trim();
break;
}
}
} catch (Exception e) {
Log.w(TAG, "Unable to read instance uuid from " + instancePath);
Timber.e(e);
// Log.w(TAG, "Unable to read instance uuid from " + instancePath);
}
return instanceUuid;
}
......
......@@ -22,6 +22,8 @@ import id.ac.stis.capi.revalidasi.briefcase.util.FileSystemUtils;
import id.ac.stis.capi.revalidasi.listener.CommonDownloadListener;
import id.ac.stis.capi.revalidasi.listener.DownloadListener;
import id.ac.stis.capi.revalidasi.listener.DownloadXmlListener;
import timber.log.Timber;
import org.opendatakit.httpclientandroidlib.HttpEntity;
import org.opendatakit.httpclientandroidlib.client.ClientProtocolException;
......@@ -136,7 +138,8 @@ public class GetXml implements DownloadXmlListener,CommonDownloadListener {
res.execute();
}
} catch (Exception e) {
Log.d("download xmlDoc",""+e);
// Log.d("download xmlDoc",""+e);
Timber.e(e);
throw new SubmissionDownloadException(e.getMessage());
}
......
......@@ -43,6 +43,48 @@
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.NoActionBar.PopupOverlay" />
<android.support.v7.widget.CardView
android:id="@+id/init_data_download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:visibility="gone"
app:cardBackgroundColor="@color/green_soft">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="8dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="@color/white"
app:srcCompat="@drawable/ic_download" />
<TextView
android:id="@+id/init_data_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:gravity="center"