Commit 86045cd4 authored by rahadi's avatar rahadi

Added Readme

parent 943b1b12
This diff is collapsed.
......@@ -207,34 +207,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
// onDoneLoading();
// }
TreeNode root = TreeNode.root();
for (int i = 0; i < 5; i++) {
TreeNode child = new ModeTreeNode("Child " + i, "child_" + i, ModeTreeNode.DOWNLOADED);
child.setLevel(0);
child.setItemClickEnable(false);
child.setExpanded(true);
root.addChild(child);
for (int j = 0; j < 2; j++) {
TreeNode grandchild = new ModeTreeNode("Grand Child " + j, "grand_child_" + j, ModeTreeNode.QUEUED);
grandchild.setLevel(j + 1);
grandchild.setItemClickEnable(false);
grandchild.setExpanded(true);
child.addChild(grandchild);
}
}
AlertDialog alertDialog = new AlertDialog.Builder(getContext())
.setTitle("VO")
.setView(new TreeView(root, getContext(), new NodeViewFactory()).getView())
.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.create();
alertDialog.show();
return v;
}
......
......@@ -17,6 +17,7 @@ import java.util.List;
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.OnEntrySavedListener;
import id.ac.stis.capi.lessthink.listeners.OnTableAddButtonClickListener;
import id.ac.stis.capi.lessthink.models.FormLabels;
import id.ac.stis.capi.lessthink.models.InstanceValues;
......@@ -33,7 +34,7 @@ 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 {
public class ListingInstanceActivity extends AppCompatActivity implements OnEntrySavedListener {
private static final String FORM_ID_KEY = "formid";
private static final String FORMNAME = "formname";
......@@ -42,7 +43,7 @@ public class ListingInstanceActivity extends AppCompatActivity {
private TableRowView tableRowView;
private TableFooterView tableFooterView;
private String formId, formName;
// private FormEntryDialogFragment entryDialogFragment;
private FormLabels labels;
private FormEntryDialogFragment entryDialogFragment;
@Override
......@@ -64,28 +65,11 @@ public class ListingInstanceActivity extends AppCompatActivity {
File file = new File(forms.get(0).getFormFilePath());
List<String> xPaths = XmlUtils.getInstanceXPathList(file);
FormLabels labels = XmlUtils.getFormLabels(formId, file, xPaths);
labels = XmlUtils.getFormLabels(formId, file, xPaths);
tableHeaderView.setColumns(labels);
List<InstanceValues> instanceValues = new LinkedList<>();
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);
refreshItem(true);
tableRowView.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -98,6 +82,7 @@ public class ListingInstanceActivity extends AppCompatActivity {
entryDialogFragment = FormEntryDialogFragment.newInstance(instanceUuid,
FormEntryDialogFragment.MODE_EDIT, false);
entryDialogFragment.show(getSupportFragmentManager(), instanceUuid);
entryDialogFragment.setOnEntrySavedListener(ListingInstanceActivity.this);
//
// Intent i =new Intent(ListingInstanceActivity.this, ListingFormEntryActivity.class);
// i.putExtra("instanceUuid", view.getTag().toString());
......@@ -113,6 +98,31 @@ public class ListingInstanceActivity extends AppCompatActivity {
});
}
private void refreshItem(boolean init) {
List<InstanceValues> instanceValues = new LinkedList<>();
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);
}
if (init) {
tableRowView.initView(instanceValues);
} else {
tableRowView.setRows(instanceValues);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, final Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
......@@ -149,4 +159,9 @@ public class ListingInstanceActivity extends AppCompatActivity {
Toast.makeText(this, "Form not exist", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onEntrySaved() {
refreshItem(false);
}
}
......@@ -23,7 +23,9 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.zxing.integration.android.IntentIntegrator;
......@@ -47,9 +49,9 @@ import java.util.Set;
import id.ac.stis.capi.R;
import id.ac.stis.capi.lessthink.adapters.HierarchyAdapter;
import id.ac.stis.capi.lessthink.listeners.OnButtonHierarchyClickListener;
import id.ac.stis.capi.lessthink.listeners.OnAnswerChangedListener;
import id.ac.stis.capi.lessthink.listeners.OnEditRutaSavedListener;
import id.ac.stis.capi.lessthink.listeners.OnButtonHierarchyClickListener;
import id.ac.stis.capi.lessthink.listeners.OnEntrySavedListener;
import id.ac.stis.capi.lessthink.models.BaseHierarchy;
import id.ac.stis.capi.lessthink.models.ButtonHierarchy;
import id.ac.stis.capi.lessthink.models.PromptHierarchy;
......@@ -132,12 +134,13 @@ public class FormEntryDialogFragment extends DialogFragment implements FormLoade
private final Object saveDialogLock = new Object();
private String instanceName;
private Uri instanceUri;
private SaveToDiskTask saveToDiskTask;
private boolean fromDetail;
private int viewMode, locationState;
private String instanceUuid, formPath;
private OnEditRutaSavedListener onEditRutaSavedListener;
private OnEntrySavedListener onEntrySavedListener;
private FormLoaderTask formLoaderTask;
private FormsDao formsDao;
private InstancesDao instancesDao;
......@@ -147,6 +150,9 @@ public class FormEntryDialogFragment extends DialogFragment implements FormLoade
private HierarchyAdapter adapter;
private ArrayList<BaseHierarchy> hierarchies;
private ProgressDialog progressDialog;
private View loadingView;
private ImageView closeButton;
private TextView dialogTitle;
public FormEntryDialogFragment() {
// Required empty public constructor
......@@ -162,13 +168,14 @@ public class FormEntryDialogFragment extends DialogFragment implements FormLoade
return fragment;
}
public void setOnEditRutaSavedListener(OnEditRutaSavedListener onEditRutaSavedListener) {
this.onEditRutaSavedListener = onEditRutaSavedListener;
public void setOnEntrySavedListener(OnEntrySavedListener onEntrySavedListener) {
this.onEntrySavedListener = onEntrySavedListener;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
instanceUuid = getArguments().getString(INSTANCE_UUID);
fromDetail = getArguments().getBoolean(FLAG_FROM_DETAIL);
......@@ -189,6 +196,8 @@ public class FormEntryDialogFragment extends DialogFragment implements FormLoade
instanceUri = ContentUris.withAppendedId(InstanceProviderAPI.InstanceColumns.CONTENT_URI,
instance.getIdInstance());
instanceName = instance.getDisplayName();
formsDao = new FormsDao();
Cursor c1 = formsDao.getFormsCursorForFormId(formId);
......@@ -226,6 +235,11 @@ public class FormEntryDialogFragment extends DialogFragment implements FormLoade
View v = inflater.inflate(R.layout.fragment_updating_dialog, null);
// questionContainer = v.findViewById(R.id.question_container);
mainContent = v.findViewById(R.id.question_container);
loadingView = v.findViewById(R.id.loading_view);
closeButton = v.findViewById(R.id.close_button);
dialogTitle = v.findViewById(R.id.dialog_title);
dialogTitle.setText(instanceName);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
mainContent.setLayoutManager(layoutManager);
......@@ -238,11 +252,14 @@ public class FormEntryDialogFragment extends DialogFragment implements FormLoade
builder.setView(v).setPositiveButton(getString(R.string.save_all_answers), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (null != onEditRutaSavedListener) {
onEditRutaSavedListener.onEditRutaSaved();
}
saveDataToDisk();
}
});
saveDataToDisk();
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
......@@ -403,6 +420,8 @@ public class FormEntryDialogFragment extends DialogFragment implements FormLoade
@Override
public void loadingComplete(FormLoaderTask task) {
loadingView.setVisibility(View.GONE);
final FormController formController = task.getFormController();
int requestCode = task.getRequestCode(); // these are bogus if
// pendingActivityResult is
......@@ -1148,6 +1167,10 @@ public class FormEntryDialogFragment extends DialogFragment implements FormLoade
public void savingComplete(SaveResult saveStatus) {
dismissProgressDialog();
dismiss();
if (null != onEntrySavedListener) {
onEntrySavedListener.onEntrySaved();
}
}
}
......@@ -5,7 +5,7 @@ package id.ac.stis.capi.lessthink.listeners;
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public interface OnEditRutaSavedListener {
void onEditRutaSaved();
public interface OnEntrySavedListener {
void onEntrySaved();
}
......@@ -112,7 +112,7 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
return currentPage;
}
public void setRows(List<InstanceValues> rows) {
public void initView(List<InstanceValues> rows) {
this.rows = rows;
this.currentPage = 1;
......@@ -190,6 +190,11 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
requestLayout();
}
public void setRows(List<InstanceValues> rows) {
this.rows = rows;
addRowChildren(1);
}
private void addRowChildren(int page) {
row.removeAllViews();
......
......@@ -74,7 +74,6 @@ import timber.log.Timber;
* @author mitchellsundt@gmail.com
*/
public final class WebUtils {
public static final String OPEN_ROSA_VERSION_HEADER = "X-OpenRosa-Version";
public static final String OPEN_ROSA_VERSION = "1.0";
public static final String HTTP_CONTENT_TYPE_TEXT_XML = "text/xml";
......
......@@ -5,6 +5,45 @@
android:layout_height="match_parent"
android:background="@android:color/white">
<android.support.constraint.ConstraintLayout
android:id="@+id/loading_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/dialog_header">
<ProgressBar
android:id="@+id/progressBar2"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="@+id/textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/please_wait"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/progressBar2" />
</android.support.constraint.ConstraintLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/question_container"
android:layout_width="match_parent"
......@@ -24,7 +63,7 @@
android:focusableInTouchMode="true">
<ImageButton
android:id="@+id/close_button"
android:id="@+id/back_button"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="50dp"
android:layout_height="wrap_content"
......@@ -32,6 +71,7 @@
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:tint="@android:color/white"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
......@@ -48,14 +88,14 @@
android:textColor="@android:color/white"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="@+id/edit_button"
app:layout_constraintEnd_toStartOf="@+id/edit_button"
app:layout_constraintBottom_toBottomOf="@+id/close_button"
app:layout_constraintEnd_toStartOf="@+id/close_button"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toEndOf="@+id/close_button"
app:layout_constraintTop_toTopOf="@+id/edit_button" />
app:layout_constraintStart_toEndOf="@+id/back_button"
app:layout_constraintTop_toTopOf="@+id/close_button" />
<ImageButton
android:id="@+id/edit_button"
android:id="@+id/close_button"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="50dp"
android:layout_height="wrap_content"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment