From e99b6beceb8d4a9343c265d5ed4be8e599f0b370 Mon Sep 17 00:00:00 2001 From: Nishon Tandukar Date: Fri, 15 Nov 2019 11:19:42 +0545 Subject: [PATCH] removes surveyform old ui; bumped version (#485) --- collect_app/build.gradle | 2 +- collect_app/internal/output.json | 2 +- collect_app/release/output.json | 2 +- collect_app/src/main/AndroidManifest.xml | 1 - .../forms/ui/FieldSightFormListFragment.java | 1 + .../naxa/survey/SurveyFormsActivity.java | 208 ------------------ .../naxa/v3/ProjectListActivityV3.java | 2 +- .../layout/activity_survey_forms.xml | 25 --- 8 files changed, 5 insertions(+), 238 deletions(-) delete mode 100644 collect_app/src/main/java/org/fieldsight/naxa/survey/SurveyFormsActivity.java delete mode 100644 collect_app/src/main/res/layouts/fieldsight/layout/activity_survey_forms.xml diff --git a/collect_app/build.gradle b/collect_app/build.gradle index 188ead77f..578c5ef35 100644 --- a/collect_app/build.gradle +++ b/collect_app/build.gradle @@ -23,7 +23,7 @@ def mapboxToken = secrets.getProperty('MAPBOX_ACCESS_TOKEN', '') def versionMajor = 3 def versionMinor = 2 -def versionPatch = 14 +def versionPatch = 15 android { compileSdkVersion(28) diff --git a/collect_app/internal/output.json b/collect_app/internal/output.json index a61b99ba1..f0d3d6f07 100644 --- a/collect_app/internal/output.json +++ b/collect_app/internal/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":3212,"versionName":"3.2.12-beta","enabled":true,"outputFile":"collect-internal3.2.12-beta.apk","fullName":"internal","baseName":"internal"},"path":"collect-internal3.2.12-beta.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":3214,"versionName":"3.2.14-beta","enabled":true,"outputFile":"collect-internal3.2.14-beta.apk","fullName":"internal","baseName":"internal"},"path":"collect-internal3.2.14-beta.apk","properties":{}}] \ No newline at end of file diff --git a/collect_app/release/output.json b/collect_app/release/output.json index b0295df00..263193e3b 100644 --- a/collect_app/release/output.json +++ b/collect_app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":3213,"versionName":"3.2.13","enabled":true,"outputFile":"collect-release3.2.13.apk","fullName":"release","baseName":"release"},"path":"collect-release3.2.13.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":3214,"versionName":"3.2.14","enabled":true,"outputFile":"collect-release3.2.14.apk","fullName":"release","baseName":"release"},"path":"collect-release3.2.14.apk","properties":{}}] \ No newline at end of file diff --git a/collect_app/src/main/AndroidManifest.xml b/collect_app/src/main/AndroidManifest.xml index 3d2463ac1..1635bdbbe 100644 --- a/collect_app/src/main/AndroidManifest.xml +++ b/collect_app/src/main/AndroidManifest.xml @@ -109,7 +109,6 @@ the specific language governing permissions and limitations under the License. - diff --git a/collect_app/src/main/java/org/fieldsight/naxa/forms/ui/FieldSightFormListFragment.java b/collect_app/src/main/java/org/fieldsight/naxa/forms/ui/FieldSightFormListFragment.java index 0beb200e0..eaba285fc 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/forms/ui/FieldSightFormListFragment.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/forms/ui/FieldSightFormListFragment.java @@ -38,6 +38,7 @@ public static FieldSightFormListFragment newInstance(String loadFormType, Site s if (site == null) { site = new Site(); site.setSite("0"); + site.setId("0"); site.setName(project.getName()); site.setProject(project.getId()); } diff --git a/collect_app/src/main/java/org/fieldsight/naxa/survey/SurveyFormsActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/survey/SurveyFormsActivity.java deleted file mode 100644 index 76ea9fde1..000000000 --- a/collect_app/src/main/java/org/fieldsight/naxa/survey/SurveyFormsActivity.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.fieldsight.naxa.survey; - -import android.content.ContentUris; -import android.content.Context; -import android.content.Intent; -import android.database.Cursor; -import android.database.CursorIndexOutOfBoundsException; -import android.net.Uri; -import android.os.Bundle; -import android.view.View; - -import androidx.annotation.Nullable; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; -import androidx.lifecycle.Observer; -import androidx.lifecycle.ViewModelProviders; -import androidx.recyclerview.widget.DefaultItemAnimator; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.google.android.material.appbar.AppBarLayout; - -import org.bcss.collect.android.R;; -import org.fieldsight.naxa.common.DialogFactory; -import org.fieldsight.naxa.common.RecyclerViewEmptySupport; -import org.fieldsight.naxa.common.SharedPreferenceUtils; -import org.fieldsight.naxa.common.ViewModelFactory; -import org.fieldsight.naxa.helpers.FSInstancesDao; -import org.fieldsight.naxa.login.model.Project; -import org.odk.collect.android.activities.CollectAbstractActivity; -import org.odk.collect.android.application.Collect; -import org.odk.collect.android.provider.FormsProviderAPI; -import org.odk.collect.android.utilities.ToastUtils; - -import java.util.List; - -import butterknife.BindView; -import butterknife.ButterKnife; -import timber.log.Timber; - -import static org.fieldsight.naxa.common.Constant.EXTRA_OBJECT; -import static org.fieldsight.naxa.common.Constant.FormDeploymentFrom.PROJECT; -import static org.fieldsight.naxa.common.SharedPreferenceUtils.isFormSaveCacheSafe; - - -public class SurveyFormsActivity extends CollectAbstractActivity implements TitleDescAdapter.OnCardClickListener { - - @BindView(R.id.toolbar) - Toolbar toolbar; - - - @BindView(R.id.appbar_general) - AppBarLayout appbarGeneral; - - @BindView(R.id.recycler_survey_form_list) - RecyclerViewEmptySupport recyclerSurveyFormList; - - private Project loadedProject; - private TitleDescAdapter adapter; - private SurveyFormViewModel surveyFormViewModel; - - public static void start(Context context, Project loadedProject) { - Intent intent = new Intent(context, SurveyFormsActivity.class); - intent.putExtra(EXTRA_OBJECT, loadedProject); - context.startActivity(intent); - } - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_survey_forms); - ButterKnife.bind(this); - - - try { - loadedProject = getIntent().getParcelableExtra(EXTRA_OBJECT); - } catch (NullPointerException e) { - ToastUtils.showLongToast(getString(R.string.dialog_unexpected_error_title)); - finish(); - } - - setupViewModel(); - setupToolbar(); - setupRecyclerView(); - - surveyFormViewModel.getByProjectId(loadedProject.getId()).observe(this, - new Observer>() { - @Override - public void onChanged(@Nullable List surveyForms) { - if (surveyForms == null){ - return; - } - - adapter.clear(); - adapter.addAll(surveyForms); - adapter.notifyDataSetChanged(); - - } - }); - - - } - - - private void setupToolbar() { - - setSupportActionBar(toolbar); - ActionBar actionBar = getSupportActionBar(); - - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - SurveyFormsActivity.super.onBackPressed(); - } - }); - - if (actionBar != null) { - actionBar.setTitle(loadedProject.getName()); - actionBar.setSubtitle("Survey Form"); - - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } - - private void setupRecyclerView() { - adapter = new TitleDescAdapter(); - adapter.setOnCardClickListener(this); - LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false); - recyclerSurveyFormList.setLayoutManager(linearLayoutManager); - recyclerSurveyFormList.setItemAnimator(new DefaultItemAnimator()); - recyclerSurveyFormList.setEmptyView(findViewById(R.id.root_layout_empty_layout), getString(R.string.empty_message, "survey form(s)"), () -> { - - }); - - recyclerSurveyFormList.setAdapter(adapter); - - } - - @Override - public void onCardClicked(SurveyForm surveyForm) { - - String projectIdForSurveyForm = "0"; - String submissionUrl = generateSubmissionUrl(PROJECT, projectIdForSurveyForm, surveyForm.getFsFormId()); - SharedPreferenceUtils.saveToPrefs(Collect.getInstance().getApplicationContext(), SharedPreferenceUtils.PREF_VALUE_KEY.KEY_URL, submissionUrl); - SharedPreferenceUtils.saveToPrefs(Collect.getInstance().getApplicationContext(), SharedPreferenceUtils.PREF_VALUE_KEY.KEY_SITE_ID, projectIdForSurveyForm); - - if (isFormSaveCacheSafe(submissionUrl, projectIdForSurveyForm)) { - fillODKForm(surveyForm.getIdString()); - } - } - - private void setupViewModel() { - ViewModelFactory factory = ViewModelFactory.getInstance(); - surveyFormViewModel = ViewModelProviders.of(this, factory).get(SurveyFormViewModel.class); - } - - protected void fillODKForm(String idString) { - try { - long formId = getFormId(idString); - Uri formUri = ContentUris.withAppendedId(FormsProviderAPI.FormsColumns.CONTENT_URI, formId); - String action = getIntent().getAction(); - - if (Intent.ACTION_PICK.equals(action)) { - // caller is waiting on a picked form - setResult(RESULT_OK, new Intent().setData(formUri)); - } else { - // caller wants to view/edit a form, so launch formentryactivity - Intent toFormEntry = new Intent(Intent.ACTION_EDIT, formUri); - toFormEntry.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - startActivity(toFormEntry); - - } - } catch (NullPointerException | NumberFormatException e) { - Timber.e(e); - DialogFactory.createGenericErrorDialog(this, e.getMessage()).show(); - Timber.e("Failed to load xml form %s", e.getMessage()); - } catch (CursorIndexOutOfBoundsException e) { - DialogFactory.createGenericErrorDialog(this, getString(R.string.msg_form_not_present)).show(); - Timber.e("Failed to load xml form %s", e.getMessage()); - } - } - - protected String generateSubmissionUrl(String formDeployedFrom, String creatorsId, String fsFormId) { - return FSInstancesDao.generateSubmissionUrl(formDeployedFrom, creatorsId, fsFormId); - } - - - protected long getFormId(String jrFormId) throws CursorIndexOutOfBoundsException, NullPointerException, NumberFormatException { - - String[] projection = new String[]{FormsProviderAPI.FormsColumns._ID, FormsProviderAPI.FormsColumns.FORM_FILE_PATH}; - String selection = FormsProviderAPI.FormsColumns.JR_FORM_ID + "=? AND " + "(" + FormsProviderAPI.FormsColumns.IS_TEMP_DOWNLOAD + " =? OR " + FormsProviderAPI.FormsColumns.IS_TEMP_DOWNLOAD + " IS NULL)"; - String[] selectionArgs = new String[]{jrFormId, "0"}; - String sortOrder = FormsProviderAPI.FormsColumns._ID + " DESC LIMIT 1"; - - Cursor cursor = getContentResolver().query(FormsProviderAPI.FormsColumns.CONTENT_URI, - projection, - selection, selectionArgs, sortOrder); - - cursor.moveToFirst(); - int columnIndex = cursor.getColumnIndex(FormsProviderAPI.FormsColumns._ID); - long formId = Long.parseLong(cursor.getString(columnIndex)); - - cursor.close(); - - return formId; - } -} diff --git a/collect_app/src/main/java/org/fieldsight/naxa/v3/ProjectListActivityV3.java b/collect_app/src/main/java/org/fieldsight/naxa/v3/ProjectListActivityV3.java index 791e181d1..37db2f903 100644 --- a/collect_app/src/main/java/org/fieldsight/naxa/v3/ProjectListActivityV3.java +++ b/collect_app/src/main/java/org/fieldsight/naxa/v3/ProjectListActivityV3.java @@ -106,7 +106,7 @@ public void onChanged() { selected++; } } - Timber.d("PROJECT list counter is %d", selected); + Timber.d("project list counter is %d", selected); if (selected > 0) { tvSyncProject.setVisibility(View.VISIBLE); tvSyncProject.setBackgroundColor(getResources().getColor(R.color.secondaryColor)); diff --git a/collect_app/src/main/res/layouts/fieldsight/layout/activity_survey_forms.xml b/collect_app/src/main/res/layouts/fieldsight/layout/activity_survey_forms.xml deleted file mode 100644 index ab9c9b128..000000000 --- a/collect_app/src/main/res/layouts/fieldsight/layout/activity_survey_forms.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - -