Commit 2ee4e7a9 authored by rahadi's avatar rahadi

Preferences modifications

parent 86045cd4
...@@ -378,7 +378,8 @@ the specific language governing permissions and limitations under the License. ...@@ -378,7 +378,8 @@ the specific language governing permissions and limitations under the License.
<!-- android:name="id.ac.stis.capi.pemutakhiran.activities.DsrtActivity" --> <!-- android:name="id.ac.stis.capi.pemutakhiran.activities.DsrtActivity" -->
<!-- android:theme="@style/VsenAppTheme" /> --> <!-- android:theme="@style/VsenAppTheme" /> -->
<activity android:name=".lessthink.activities.ListingInstanceActivity"></activity> <activity android:name=".lessthink.activities.InstanceActivity"></activity>
<activity android:name=".lessthink.activities.InstancePreferenceActivity" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -25,6 +25,7 @@ import android.net.NetworkInfo; ...@@ -25,6 +25,7 @@ import android.net.NetworkInfo;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
...@@ -42,18 +43,33 @@ import android.widget.TextView; ...@@ -42,18 +43,33 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import id.ac.stis.capi.R; import id.ac.stis.capi.R;
import id.ac.stis.capi.collectiva.CapiInstance;
import id.ac.stis.capi.collectiva.adapter.CapiInstanceAdapter;
import id.ac.stis.capi.collectiva.preferences.CapiInstancePreferences;
import id.ac.stis.capi.collectiva.preferences.Constants;
import id.ac.stis.capi.lessthink.activities.InstancePreferenceActivity;
import id.ac.stis.capi.lessthink.fragments.InstancePreferenceFragment;
import id.ac.stis.capi.lessthink.models.FormLabels;
import id.ac.stis.capi.lessthink.models.InstanceValues;
import id.ac.stis.capi.lessthink.preferences.PreferencesAPI;
import id.ac.stis.capi.lessthink.preferences.PreferencesManager;
import id.ac.stis.capi.lessthink.utils.XmlUtils;
import id.ac.stis.capi.odk.activities.FormEntryActivity; import id.ac.stis.capi.odk.activities.FormEntryActivity;
import id.ac.stis.capi.odk.activities.GoogleSheetsUploaderActivity; import id.ac.stis.capi.odk.activities.GoogleSheetsUploaderActivity;
import id.ac.stis.capi.odk.activities.InstanceUploaderActivity; import id.ac.stis.capi.odk.activities.InstanceUploaderActivity;
import id.ac.stis.capi.odk.application.Collect; import id.ac.stis.capi.odk.application.Collect;
import id.ac.stis.capi.collectiva.CapiInstance;
import id.ac.stis.capi.collectiva.preferences.CapiInstancePreferences;
import id.ac.stis.capi.collectiva.ParseXml;
import id.ac.stis.capi.collectiva.preferences.Constants;
import id.ac.stis.capi.collectiva.adapter.CapiInstanceAdapter;
import id.ac.stis.capi.odk.dao.FormsDao; import id.ac.stis.capi.odk.dao.FormsDao;
import id.ac.stis.capi.odk.dao.InstancesDao; 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.dto.Instance;
import id.ac.stis.capi.odk.listeners.DeleteInstancesListener; import id.ac.stis.capi.odk.listeners.DeleteInstancesListener;
import id.ac.stis.capi.odk.listeners.DiskSyncListener; import id.ac.stis.capi.odk.listeners.DiskSyncListener;
...@@ -69,11 +85,6 @@ import id.ac.stis.capi.odk.utilities.ApplicationConstants; ...@@ -69,11 +85,6 @@ import id.ac.stis.capi.odk.utilities.ApplicationConstants;
import id.ac.stis.capi.odk.utilities.PlayServicesUtil; import id.ac.stis.capi.odk.utilities.PlayServicesUtil;
import id.ac.stis.capi.odk.utilities.ToastUtils; import id.ac.stis.capi.odk.utilities.ToastUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import static id.ac.stis.capi.odk.utilities.ApplicationConstants.SortingOrder.BY_DATE_ASC; import static id.ac.stis.capi.odk.utilities.ApplicationConstants.SortingOrder.BY_DATE_ASC;
import static id.ac.stis.capi.odk.utilities.ApplicationConstants.SortingOrder.BY_DATE_DESC; import static id.ac.stis.capi.odk.utilities.ApplicationConstants.SortingOrder.BY_DATE_DESC;
import static id.ac.stis.capi.odk.utilities.ApplicationConstants.SortingOrder.BY_NAME_ASC; import static id.ac.stis.capi.odk.utilities.ApplicationConstants.SortingOrder.BY_NAME_ASC;
...@@ -90,14 +101,17 @@ import static id.ac.stis.capi.odk.utilities.ApplicationConstants.SortingOrder.BY ...@@ -90,14 +101,17 @@ import static id.ac.stis.capi.odk.utilities.ApplicationConstants.SortingOrder.BY
public class CapiInstanceActivity extends AppCompatActivity public class CapiInstanceActivity extends AppCompatActivity
implements DiskSyncListener, DeleteInstancesListener, implements DiskSyncListener, DeleteInstancesListener,
CapiInstanceAdapter.MenuListener, SearchView.OnQueryTextListener { CapiInstanceAdapter.MenuListener, SearchView.OnQueryTextListener {
private static final String INSTANCE_LIST_ACTIVITY_SORTING_ORDER = "instanceListActivitySortingOrder"; public static final String FORM_ID_KEY = "formid";
public static final String FORMNAME = "formname";
static final String TAG = CapiInstanceActivity.class.getSimpleName(); static final String TAG = CapiInstanceActivity.class.getSimpleName();
private static final String INSTANCE_LIST_ACTIVITY_SORTING_ORDER = "instanceListActivitySortingOrder";
private static final int INSTANCE_UPLOADER = 0;
protected String[] mSortingOptions;
String formName;
String formIDKey;
DeleteInstancesTask mDeleteInstancesTask = null;
private InstanceSyncTask instanceSyncTask; private InstanceSyncTask instanceSyncTask;
private Integer mSelectedSortingOrder; private Integer mSelectedSortingOrder;
protected String[] mSortingOptions;
//modification //modification
private RecyclerView recycleView; private RecyclerView recycleView;
private LinearLayout progressBarHolder, messageHolder; private LinearLayout progressBarHolder, messageHolder;
...@@ -106,15 +120,6 @@ public class CapiInstanceActivity extends AppCompatActivity ...@@ -106,15 +120,6 @@ public class CapiInstanceActivity extends AppCompatActivity
private CapiInstanceAdapter adapter; private CapiInstanceAdapter adapter;
private SharedPreferences capiPref; private SharedPreferences capiPref;
private static final String FORM_ID_KEY = "formid";
private static final String FORMNAME = "formname";
private static final int INSTANCE_UPLOADER = 0;
String formName;
String formIDKey;
DeleteInstancesTask mDeleteInstancesTask = null;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -135,11 +140,11 @@ public class CapiInstanceActivity extends AppCompatActivity ...@@ -135,11 +140,11 @@ public class CapiInstanceActivity extends AppCompatActivity
}; };
capiPref = getSharedPreferences(CapiInstancePreferences.COLLECTIVA_PREFERENCES_KEY, MODE_PRIVATE); capiPref = getSharedPreferences(CapiInstancePreferences.COLLECTIVA_PREFERENCES_KEY, MODE_PRIVATE);
formName = getString(R.string.instance_list_title,getIntent().getStringExtra(FORMNAME)); formName = getString(R.string.instance_list_title, getIntent().getStringExtra(FORMNAME));
formIDKey = getIntent().getStringExtra(FORM_ID_KEY); formIDKey = getIntent().getStringExtra(FORM_ID_KEY);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
if (null != getSupportActionBar()){ if (null != getSupportActionBar()) {
getSupportActionBar().setTitle(formName); getSupportActionBar().setTitle(formName);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
...@@ -170,7 +175,6 @@ public class CapiInstanceActivity extends AppCompatActivity ...@@ -170,7 +175,6 @@ public class CapiInstanceActivity extends AppCompatActivity
} }
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) { protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (resultCode == RESULT_CANCELED) { if (resultCode == RESULT_CANCELED) {
...@@ -193,20 +197,20 @@ public class CapiInstanceActivity extends AppCompatActivity ...@@ -193,20 +197,20 @@ public class CapiInstanceActivity extends AppCompatActivity
super.onActivityResult(requestCode, resultCode, intent); super.onActivityResult(requestCode, resultCode, intent);
} }
private void onStartLoading(){ private void onStartLoading() {
Log.d(TAG,"on start loading"); Log.d(TAG, "on start loading");
progressBarHolder.setVisibility(View.VISIBLE); progressBarHolder.setVisibility(View.VISIBLE);
messageHolder.setVisibility(View.GONE); messageHolder.setVisibility(View.GONE);
} }
private void onErrorLoading(String message){ private void onErrorLoading(String message) {
progressBarHolder.setVisibility(View.GONE); progressBarHolder.setVisibility(View.GONE);
messageError.setText(message); messageError.setText(message);
messageHolder.setVisibility(View.VISIBLE); messageHolder.setVisibility(View.VISIBLE);
} }
private void onDoneLoading(){ private void onDoneLoading() {
Log.d("DEBUGCOLL","on done loading"); Log.d("DEBUGCOLL", "on done loading");
progressBarHolder.setVisibility(View.GONE); progressBarHolder.setVisibility(View.GONE);
messageHolder.setVisibility(View.GONE); messageHolder.setVisibility(View.GONE);
} }
...@@ -253,7 +257,7 @@ public class CapiInstanceActivity extends AppCompatActivity ...@@ -253,7 +257,7 @@ public class CapiInstanceActivity extends AppCompatActivity
List<CapiInstance> dataInstances = getDataInstance(); List<CapiInstance> dataInstances = getDataInstance();
adapter = new CapiInstanceAdapter(this, dataInstances, formName, this); adapter = new CapiInstanceAdapter(this, dataInstances, formName, this);
recycleView.setAdapter(adapter); recycleView.setAdapter(adapter);
if(dataInstances.size()<1){ if (dataInstances.size() < 1) {
onErrorLoading("Belum ada respons untuk kuesioner \"" + formName + "\""); onErrorLoading("Belum ada respons untuk kuesioner \"" + formName + "\"");
} }
} }
...@@ -268,41 +272,63 @@ public class CapiInstanceActivity extends AppCompatActivity ...@@ -268,41 +272,63 @@ public class CapiInstanceActivity extends AppCompatActivity
private List<CapiInstance> getDataInstance() { private List<CapiInstance> getDataInstance() {
try { try {
String titleSelected = capiPref PreferencesManager manager = PreferencesManager.getInstance();
.getString(formIDKey+"_"+ CapiInstancePreferences.TITLE_RESPONS_KEY, "");
HashSet<String> subtitles = (HashSet<String>) String titleSelected = (String) manager.getByFormId(PreferencesAPI.KEY_TITLE, formIDKey);
capiPref.getStringSet(formIDKey+"_"+ CapiInstancePreferences.SUBTITLE_RESPONS_KEY, // String titleSelected = capiPref
new HashSet<String>()); // .getString(formIDKey + "_" + CapiInstancePreferences.TITLE_RESPONS_KEY, "");
HashSet<String> subtitles = (HashSet<String>) manager.getByFormId(PreferencesAPI.KEY_SUBTITLE, formIDKey);
// HashSet<String> subtitles = (HashSet<String>)
// capiPref.getStringSet(formIDKey + "_" + CapiInstancePreferences.SUBTITLE_RESPONS_KEY,
// new HashSet<String>());
HashSet<String> arrays = new HashSet<>(); HashSet<String> arrays = new HashSet<>();
arrays.add(titleSelected); arrays.add(titleSelected);
arrays.addAll(subtitles); arrays.addAll(subtitles);
Log.d("DEBUGCOLL","getting information for "+arrays); Log.d("DEBUGCOLL", "getting information for " + arrays);
String selection = InstanceColumns.LATEST + " =? AND " + String selection = InstanceColumns.LATEST + " =? AND " +
InstanceColumns.JR_FORM_ID + " =?"; InstanceColumns.JR_FORM_ID + " =?";
String[] selectionArgs = new String[]{InstanceProviderAPI.LATEST_VERSION,formIDKey}; String[] selectionArgs = new String[]{InstanceProviderAPI.LATEST_VERSION, formIDKey};
InstancesDao instancesDao = new InstancesDao(); InstancesDao instancesDao = new InstancesDao();
Cursor data = instancesDao.getInstancesCursor(null, selection, selectionArgs, getSortingOrder()); Cursor data = instancesDao.getInstancesCursor(null, selection, selectionArgs, getSortingOrder());
List<Instance> instanceList = instancesDao.getInstancesFromCursor(data); List<Instance> instanceList = instancesDao.getInstancesFromCursor(data);
FormsDao formsDao = new FormsDao();
Form form = formsDao.getFormsFromCursor(formsDao.getFormsCursorForFormId(formIDKey)).get(0);
String formPath = form.getFormFilePath();
File formFile = new File(formPath);
List<String> xpaths = new ArrayList<>(arrays);
FormLabels labels = XmlUtils.getFormLabels(formIDKey, formFile, xpaths);
//filtered by form id //filtered by form id
List<CapiInstance> newInstance = new ArrayList<>(); List<CapiInstance> newInstance = new ArrayList<>();
for (Instance instance : instanceList) { for (Instance instance : instanceList) {
CapiInstance capiInstance = new CapiInstance(instance); CapiInstance capiInstance = new CapiInstance(instance);
if(arrays.size()>0) { if (arrays.size() > 0) {
HashMap<String, String> informations = ParseXml // HashMap<String, String> informations = ParseXml
.getLoadedXmlValues(instance.getInstanceFilePath(), arrays); // .getLoadedXmlValues(instance.getInstanceFilePath(), arrays);
if(!titleSelected.equals("")) {
capiInstance.setPrimaryTitle(informations.get(titleSelected)); HashMap<String, String> informations = new HashMap<>();
informations.remove(titleSelected); File file = new File(instance.getInstanceFilePath());
InstanceValues values = XmlUtils.getInstanceValues(instance.getInstanceUuid(), file, labels);
Set<String> parsedXpaths = values.getXPaths();
for(String parsed : parsedXpaths) {
if(parsed.equals(titleSelected)) {
capiInstance.setPrimaryTitle(values.getInstanceValue(parsed));
} else {
informations.put(labels.getFormLabel(parsed), values.getInstanceValue(parsed));
}
} }
if(subtitles.size()>0) capiInstance.setInformation(informations);
if (subtitles.size() > 0) capiInstance.setInformation(informations);
} }
newInstance.add(capiInstance); newInstance.add(capiInstance);
} }
return newInstance; return newInstance;
}catch (Exception e){ } catch (Exception e) {
Toast.makeText(this, "Trouble when getting data instance", Toast.makeText(this, "Trouble when getting data instance",
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
return new ArrayList<>(); return new ArrayList<>();
...@@ -379,9 +405,23 @@ public class CapiInstanceActivity extends AppCompatActivity ...@@ -379,9 +405,23 @@ public class CapiInstanceActivity extends AppCompatActivity
else Toast.makeText(this, "Semua respon sudah diunggah", Toast.LENGTH_SHORT).show(); else Toast.makeText(this, "Semua respon sudah diunggah", Toast.LENGTH_SHORT).show();
break; break;
case R.id.action_instance_preferences: case R.id.action_instance_preferences:
Intent intent = new Intent(this, CapiInstancePreferences.class); // Intent intent = new Intent(this, CapiInstancePreferences.class);
intent.putExtra(FORM_ID_KEY, formIDKey); Intent intent = new Intent(this, InstancePreferenceActivity.class);
Bundle extra = new Bundle();
extra.putString(InstancePreferenceActivity.KEY_FORM_ID, formIDKey);
extra.putString(InstancePreferenceActivity.KEY_FORM_NAME, getIntent().getStringExtra(FORMNAME));
intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, InstancePreferenceFragment.class.getName());
intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, extra);
intent.putExtra(InstancePreferenceActivity.KEY_FORM_ID, formIDKey);
intent.putExtra(InstancePreferenceActivity.KEY_FORM_NAME, getIntent().getStringExtra(FORMNAME));
startActivity(intent); startActivity(intent);
finish();
break; break;
case android.R.id.home: case android.R.id.home:
onBackPressed(); onBackPressed();
...@@ -410,6 +450,7 @@ public class CapiInstanceActivity extends AppCompatActivity ...@@ -410,6 +450,7 @@ public class CapiInstanceActivity extends AppCompatActivity
saveSelectedSortingOrder(position); saveSelectedSortingOrder(position);
updateAdapter(); updateAdapter();
} }
private void saveSelectedSortingOrder(int selectedStringOrder) { private void saveSelectedSortingOrder(int selectedStringOrder) {
mSelectedSortingOrder = selectedStringOrder; mSelectedSortingOrder = selectedStringOrder;
PreferenceManager.getDefaultSharedPreferences(Collect.getInstance()) PreferenceManager.getDefaultSharedPreferences(Collect.getInstance())
...@@ -431,36 +472,36 @@ public class CapiInstanceActivity extends AppCompatActivity ...@@ -431,36 +472,36 @@ public class CapiInstanceActivity extends AppCompatActivity
return mSelectedSortingOrder; return mSelectedSortingOrder;
} }
private void fillBlankForm(){ private void fillBlankForm() {
Cursor formslist = new FormsDao().getFormsCursor(); Cursor formslist = new FormsDao().getFormsCursor();
//getting id //getting id
long itemIdPosition = -1; long itemIdPosition = -1;
if(formslist.moveToFirst()){ if (formslist.moveToFirst()) {
do { do {
if(formslist.getString(formslist.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID)).equals(formIDKey)){ if (formslist.getString(formslist.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID)).equals(formIDKey)) {
itemIdPosition = formslist.getLong(formslist.getColumnIndex(FormsProviderAPI.FormsColumns._ID)); itemIdPosition = formslist.getLong(formslist.getColumnIndex(FormsProviderAPI.FormsColumns._ID));
} }
}while (formslist.moveToNext()); } while (formslist.moveToNext());
} }
if(itemIdPosition>-1){ if (itemIdPosition > -1) {
// get uri to form // 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 // caller wants to view/edit a form, so launch formentryactivity
Intent intent = new Intent(Intent.ACTION_EDIT, formUri); Intent intent = new Intent(Intent.ACTION_EDIT, formUri);
intent.putExtra("fillblankform",true); intent.putExtra("fillblankform", true);
intent.putExtra(Constants.CURRENT_FORMNAME,getIntent().getStringExtra(FORMNAME)); intent.putExtra(Constants.CURRENT_FORMNAME, getIntent().getStringExtra(FORMNAME));
intent.putExtra(ApplicationConstants.BundleKeys.FORM_MODE, ApplicationConstants.FormModes.EDIT_SAVED); intent.putExtra(ApplicationConstants.BundleKeys.FORM_MODE, ApplicationConstants.FormModes.EDIT_SAVED);
startActivity(intent); startActivity(intent);
}else { } else {
//xxxseharusnya tidak terjadi, tidak mungkin itemIdposition < 1 //xxxseharusnya tidak terjadi, tidak mungkin itemIdposition < 1
Toast.makeText(this, "Form not exist", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Form not exist", Toast.LENGTH_SHORT).show();
} }
} }
//button function //button function
public void uploadInstance(long[] instanceIds){ public void uploadInstance(long[] instanceIds) {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(
Context.CONNECTIVITY_SERVICE); Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = connectivityManager.getActiveNetworkInfo(); NetworkInfo ni = connectivityManager.getActiveNetworkInfo();
...@@ -511,7 +552,7 @@ public class CapiInstanceActivity extends AppCompatActivity ...@@ -511,7 +552,7 @@ public class CapiInstanceActivity extends AppCompatActivity
@Override @Override
public void onMenuSelect(int mode, long[] instanceId) { public void onMenuSelect(int mode, long[] instanceId) {
switch (mode){ switch (mode) {
case CapiInstanceAdapter.MENU_UPLOAD: case CapiInstanceAdapter.MENU_UPLOAD:
uploadInstance(instanceId); uploadInstance(instanceId);
break; break;
......
...@@ -88,8 +88,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList ...@@ -88,8 +88,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
private static final String FORM_VERSION_KEY = "formversion"; private static final String FORM_VERSION_KEY = "formversion";
private static final String HAS_BEEN_DOWNLOADED = "hasbeendownloaded"; 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 EXIT = true;
private static final boolean DO_NOT_EXIT = false; private static final boolean DO_NOT_EXIT = false;
...@@ -210,12 +208,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList ...@@ -210,12 +208,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
return v; return v;
} }
@Override
public void onResume() {
super.onResume();
onRefreshPage();
}
public void refreshAfterSync() { public void refreshAfterSync() {
setUpDownloadedFormsOffline(); setUpDownloadedFormsOffline();
} }
...@@ -241,13 +233,11 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList ...@@ -241,13 +233,11 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
String formName = c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.DISPLAY_NAME)); String formName = c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.DISPLAY_NAME));
String formVersion = c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID)); String formVersion = c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID));
String formId = 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(FORMNAME, formName);
item.put(FORM_ID_KEY, formId); item.put(FORM_ID_KEY, formId);
item.put(FORM_VERSION_KEY, formVersion); item.put(FORM_VERSION_KEY, formVersion);
item.put(HAS_BEEN_DOWNLOADED, "true"); item.put(HAS_BEEN_DOWNLOADED, "true");
item.put(FORM_TYPE_KEY, formType);
downloadedFormsBefore.add(item); downloadedFormsBefore.add(item);
...@@ -451,8 +441,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList ...@@ -451,8 +441,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
if (item.get(HAS_BEEN_DOWNLOADED) != null && item.get(HAS_BEEN_DOWNLOADED).equals("true")) { if (item.get(HAS_BEEN_DOWNLOADED) != null && item.get(HAS_BEEN_DOWNLOADED).equals("true")) {
if (isFormInActiveSurvey(item)) { if (isFormInActiveSurvey(item)) {
item.put(FORM_TYPE_KEY, c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.FORM_TYPE)));
downloadedFilteredFormList.add(item); downloadedFilteredFormList.add(item);
} }
} else { } else {
...@@ -463,8 +451,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList ...@@ -463,8 +451,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
} else { } else {
//has been downloaded //has been downloaded
item.put(HAS_BEEN_DOWNLOADED, "true"); 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); if (isFormInActiveSurvey(item)) downloadedFilteredFormList.add(item);
} }
} }
...@@ -529,11 +515,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList ...@@ -529,11 +515,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
item.put(FORM_ID_KEY, details.formID); item.put(FORM_ID_KEY, details.formID);
item.put(FORM_VERSION_KEY, details.formVersion); 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)) { if (!mFormListContain(details.formName)) {
// Insert the new form in alphabetical order. // Insert the new form in alphabetical order.
if (mFormList.size() == 0) { if (mFormList.size() == 0) {
......
...@@ -54,7 +54,6 @@ public class CapiInstancePreferences extends AppCompatActivity ...@@ -54,7 +54,6 @@ public class CapiInstancePreferences extends AppCompatActivity
private View constraintOption; private View constraintOption;
private View advancedSetting; private View advancedSetting;