diff --git a/collect_app/src/main/AndroidManifest.xml b/collect_app/src/main/AndroidManifest.xml
index 13b0b922a..d365341dc 100644
--- a/collect_app/src/main/AndroidManifest.xml
+++ b/collect_app/src/main/AndroidManifest.xml
@@ -121,7 +121,7 @@
-
+
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/common/Constant.java b/collect_app/src/main/java/org/fieldsight/naxa/common/Constant.java
index d54d0d141..68c412371 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/common/Constant.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/common/Constant.java
@@ -73,7 +73,7 @@ public static final class NotificationType {
public static final class FormType {
public static final String SCHEDULE = "schedule";
public static final String STAGED = "stage";
- public static final String GENERAl = "general";
+ public static final String GENERAL = "general";
public static final String SURVEY = "survey";
}
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/common/GSONInstance.java b/collect_app/src/main/java/org/fieldsight/naxa/common/GSONInstance.java
index b126c9c2b..2c0f2e262 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/common/GSONInstance.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/common/GSONInstance.java
@@ -8,10 +8,10 @@ private GSONInstance(){
}
- private final static Gson gson = new Gson();
+ private final static Gson GSON = new Gson();
public static Gson getInstance() {
- return gson;
+ return GSON;
}
}
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/common/ViewUtils.java b/collect_app/src/main/java/org/fieldsight/naxa/common/ViewUtils.java
index d9afec84b..a7de3aebe 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/common/ViewUtils.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/common/ViewUtils.java
@@ -32,7 +32,7 @@ private ViewUtils(){
}
- private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1);
+ private static final AtomicInteger S_NEXT_GENERATED_ID = new AtomicInteger(1);
public static int dp2px(Context context, int dp) {
@@ -137,13 +137,13 @@ static Drawable getProgressBarIndeterminate() {
*/
public static int generateViewId() {
for (; ; ) {
- final int result = sNextGeneratedId.get();
+ final int result = S_NEXT_GENERATED_ID.get();
// aapt-generated IDs have the high byte nonzero; clamp to the range under that.
int newValue = result + 1;
if (newValue > 0x00FFFFFF) {
newValue = 1; // Roll over to 1, not 0.
}
- if (sNextGeneratedId.compareAndSet(result, newValue)) {
+ if (S_NEXT_GENERATED_ID.compareAndSet(result, newValue)) {
return result;
}
}
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/educational/EduMat_ViewImageDetailsActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/educational/EduMatImageDetailsActivity.java
similarity index 97%
rename from collect_app/src/main/java/org/fieldsight/naxa/educational/EduMat_ViewImageDetailsActivity.java
rename to collect_app/src/main/java/org/fieldsight/naxa/educational/EduMatImageDetailsActivity.java
index 39f3e8714..a0c3826d5 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/educational/EduMat_ViewImageDetailsActivity.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/educational/EduMatImageDetailsActivity.java
@@ -23,7 +23,7 @@
* Created by susan on 7/18/2017.
*/
-public class EduMat_ViewImageDetailsActivity extends CollectAbstractActivity {
+public class EduMatImageDetailsActivity extends CollectAbstractActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/educational/EducationalMaterialRecyclerViewAdapter.java b/collect_app/src/main/java/org/fieldsight/naxa/educational/EducationalMaterialRecyclerViewAdapter.java
index 538f8916c..7e9ab59e6 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/educational/EducationalMaterialRecyclerViewAdapter.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/educational/EducationalMaterialRecyclerViewAdapter.java
@@ -219,7 +219,7 @@ private void configureViewHolderImage(ViewHolderImage vh2, int position) {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
- Intent intent = new Intent(context, EduMat_ViewImageDetailsActivity.class);
+ Intent intent = new Intent(context, EduMatImageDetailsActivity.class);
bundle.putSerializable("IMAGE_URL_ON", edu_image_model.getThumbImageOn());
bundle.putSerializable("IMAGE_URL_OFF", edu_image_model.getThumbImageOff());
bundle.putSerializable("IMAGE_TITLE", edu_image_model.getTitle());
@@ -233,7 +233,7 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
Bundle bundle = new Bundle();
- Intent intent = new Intent(context, EduMat_ViewImageDetailsActivity.class);
+ Intent intent = new Intent(context, EduMatImageDetailsActivity.class);
bundle.putSerializable("IMAGE_URL_ON", edu_image_model.getThumbImageOn());
bundle.putSerializable("IMAGE_URL_OFF", edu_image_model.getThumbImageOff());
bundle.putSerializable("IMAGE_TITLE", edu_image_model.getTitle());
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/firebase/FieldSightFirebaseMessagingService.java b/collect_app/src/main/java/org/fieldsight/naxa/firebase/FieldSightFirebaseMessagingService.java
index 126961498..3e4be199b 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/firebase/FieldSightFirebaseMessagingService.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/firebase/FieldSightFirebaseMessagingService.java
@@ -36,7 +36,7 @@
public class FieldSightFirebaseMessagingService extends FirebaseMessagingService {
- private final static AtomicInteger notificationId = new AtomicInteger(0);
+ private final static AtomicInteger NOTIFICATION_ID = new AtomicInteger(0);
public static final String NEW_FORM = "New Form";
@@ -226,10 +226,6 @@ private void parseNotificationData(Map notificationData) {
if (notificationData.containsKey("form_type")) {
formType = notificationData.get("form_type");
}
- if (notificationData.containsKey("form")) {
- String form = notificationData.get("form");
- }
-
if (notificationData.containsKey("is_deployed")) {
isDeployed = notificationData.get("is_deployed");
}
@@ -260,7 +256,7 @@ private void parseNotificationData(Map notificationData) {
public static int getID() {
- return notificationId.incrementAndGet();
+ return NOTIFICATION_ID.incrementAndGet();
}
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/firebase/NotificationUtils.java b/collect_app/src/main/java/org/fieldsight/naxa/firebase/NotificationUtils.java
index ac66147af..37cdc7a2a 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/firebase/NotificationUtils.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/firebase/NotificationUtils.java
@@ -27,7 +27,7 @@ public class NotificationUtils {
public static String DOWNLOAD_ACTION = "download.action";
private static int smallIcon = R.drawable.ic_notification_icon;
- private static final String channelID = "All Notifications";
+ private static final String CHANNEL_ID = "All Notifications";
public NotificationUtils() {
@@ -38,14 +38,14 @@ private static int getUniqueMessageId() {
}
- public int notifyAction(Context ctx, String title, String content, String actionName) {
+ public int notifyAction(Context ctx, String title, String content) {
int id = getUniqueMessageId();
sendNotification(
id,
ctx,
createNotification(ctx.getApplicationContext(), content,
title, false,
- null, actionName));
+ null));
return id;
}
@@ -59,19 +59,19 @@ public static int notifyNormal(Context ctx, String title, String content) {
ctx,
createNotification(ctx.getApplicationContext(), content,
title, false,
- null, null));
+ null));
return id;
}
- public int notifyOnGoing(Context ctx, String title, String content, String actionName) {
+ public int notifyOnGoing(Context ctx, String title, String content) {
int id = getUniqueMessageId();
sendNotification(
id,
ctx,
createNotification(ctx.getApplicationContext(), content,
title, true,
- null, actionName));
+ null));
return id;
}
@@ -80,7 +80,7 @@ public static int createProgressNotification(Context ctx, String text) {
mNotifyManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
- mBuilder = new NotificationCompat.Builder(ctx, channelID);
+ mBuilder = new NotificationCompat.Builder(ctx, CHANNEL_ID);
mBuilder.setContentTitle(ctx.getString(R.string.app_name))
.setContentText(text)
.setSmallIcon(android.R.drawable.stat_sys_download)
@@ -98,7 +98,7 @@ public static void createStackNotification(Context context, String groupId, Inte
PendingIntent p = intent != null ? PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) : null;
- androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelID)
+ androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setContentIntent(p)
.setContentTitle(contentTitle)
.setContentText(contentText)
@@ -157,7 +157,7 @@ public static int createProgressNotification(int notificationId, String title) {
NotificationManager manager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelID)
+ androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(android.R.drawable.stat_sys_download)
.setAutoCancel(true)
.setContentTitle(title)
@@ -183,7 +183,7 @@ public static int createProgressNotification() {
NotificationManager manager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelID)
+ androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(android.R.drawable.stat_sys_download)
.setAutoCancel(true)
.setContentTitle("Looking for educational materials")
@@ -205,7 +205,7 @@ static void finishedProgressNotification(int notificationId, String msg) {
NotificationManager manager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelID)
+ androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(android.R.drawable.stat_sys_download_done)
.setContentText(msg);
@@ -227,7 +227,7 @@ public static void notifyHeadsUp(String title, String msg) {
NotificationManager manager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelID)
+ androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification_icon)
.setContentTitle(title)
.setTicker(msg)
@@ -250,7 +250,7 @@ public static void updateProgressNotification(int notificationId, String msg, in
NotificationManager manager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelID)
+ androidx.core.app.NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(android.R.drawable.stat_sys_download)
.setContentText(msg)
.setProgress(total, progress, false);
@@ -267,7 +267,7 @@ public static int createProgressNotification(Context ctx) {
mNotifyManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
- mBuilder = new NotificationCompat.Builder(ctx, channelID);
+ mBuilder = new NotificationCompat.Builder(ctx, CHANNEL_ID);
mBuilder.setContentTitle(ctx.getString(R.string.app_name))
.setContentText("Downloading Forms")
.setSmallIcon(android.R.drawable.stat_sys_download).setTicker("Downloading Forms");
@@ -320,7 +320,7 @@ private static void sendNotification(int id, Context ctx,
**/
private static Notification createNotification(Context ctx,
CharSequence tickerText, CharSequence contentText,
- boolean isOngoingNotification, String notificationSound, String actionName) {
+ boolean isOngoingNotification, String notificationSound) {
int icon = R.drawable.ic_notification_icon;
long when = System.currentTimeMillis();
@@ -371,10 +371,10 @@ public static void cancelNotification(int id) {
}
}
- private final static AtomicInteger c = new AtomicInteger(0);
+ private final static AtomicInteger ATOMIC_INTEGER = new AtomicInteger(0);
public static int getID() {
- return c.incrementAndGet();
+ return ATOMIC_INTEGER.incrementAndGet();
}
public static int notifyAPI(String title, String msg) {
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlagFormRemoteSource.java b/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlagFormRemoteSource.java
index 5519b09ae..b5ee8144c 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlagFormRemoteSource.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlagFormRemoteSource.java
@@ -74,12 +74,10 @@ public ObservableSource apply(String s) {
private Single getKOBOForm(FieldSightNotification notificationFormDetail) {
- String fsFormId = notificationFormDetail.getFsFormId();
- String siteId = notificationFormDetail.getSiteId();
String formName = notificationFormDetail.getFormName();
String fsFormSubmissionId = notificationFormDetail.getFormSubmissionId();
String jrFormId = "";
- return getODKForm(fsFormId, siteId, formName, fsFormSubmissionId, jrFormId);
+ return getODKForm( formName, fsFormSubmissionId, jrFormId);
}
@@ -103,7 +101,7 @@ public void getODKForm(String formName, String fsSubmissionId, String jrFormId,
}
- private Single getODKForm(String fsFormId, String siteId, String formName, String fsFormSubmissionId, String jrFormId) {
+ private Single getODKForm(String formName, String fsFormSubmissionId, String jrFormId) {
return Single.create(emitter -> {
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlaggedInstanceActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlaggedInstanceActivity.java
index 8b3788bc0..1ca62db3e 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlaggedInstanceActivity.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/flagform/FlaggedInstanceActivity.java
@@ -11,11 +11,6 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.appcompat.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
@@ -25,13 +20,12 @@
import android.widget.TextView;
import android.widget.Toast;
-import org.apache.commons.io.FilenameUtils;
+import androidx.annotation.NonNull;
+import androidx.appcompat.widget.Toolbar;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
import org.fieldsight.collect.android.R;
-import org.odk.collect.android.application.Collect;
-import org.odk.collect.android.listeners.DownloadFormsTaskListener;
-import org.odk.collect.android.logic.FormDetails;
-import org.odk.collect.android.provider.FormsProviderAPI;
-import org.odk.collect.android.provider.InstanceProviderAPI;
import org.fieldsight.naxa.BaseActivity;
import org.fieldsight.naxa.common.Constant;
import org.fieldsight.naxa.common.DialogFactory;
@@ -41,6 +35,7 @@
import org.fieldsight.naxa.common.exception.InstanceDownloadFailedException;
import org.fieldsight.naxa.common.rx.RetrofitException;
import org.fieldsight.naxa.data.FieldSightNotification;
+import org.fieldsight.naxa.helpers.FSInstancesDao;
import org.fieldsight.naxa.network.APIEndpoint;
import org.fieldsight.naxa.network.ApiInterface;
import org.fieldsight.naxa.network.ServiceGenerator;
@@ -49,8 +44,12 @@
import org.fieldsight.naxa.notificationslist.NotificationImageAdapter;
import org.fieldsight.naxa.site.FragmentHostActivity;
import org.fieldsight.naxa.site.db.SiteLocalSource;
+import org.odk.collect.android.application.Collect;
import org.odk.collect.android.dao.FormsDao;
-import org.fieldsight.naxa.helpers.FSInstancesDao;
+import org.odk.collect.android.listeners.DownloadFormsTaskListener;
+import org.odk.collect.android.logic.FormDetails;
+import org.odk.collect.android.provider.FormsProviderAPI;
+import org.odk.collect.android.provider.InstanceProviderAPI;
import org.odk.collect.android.tasks.DownloadFormsTask;
import org.odk.collect.android.utilities.ApplicationConstants;
import org.odk.collect.android.utilities.ToastUtils;
@@ -136,9 +135,6 @@ protected void onCreate(Bundle savedInstanceState) {
}
private void setupSiteCard(FieldSightNotification loadedFieldSightNotification) {
- String siteName = loadedFieldSightNotification.getSiteName();
- String siteIdentifier = loadedFieldSightNotification.getSiteIdentifier();
-
SiteLocalSource.getInstance().getBySiteId(loadedFieldSightNotification.getSiteId())
.observe(this, site -> {
if (site == null) {
@@ -248,7 +244,6 @@ protected long getFormId(String jrFormId) throws CursorIndexOutOfBoundsException
String[] projection = new String[]{FormsProviderAPI.FormsColumns._ID, FormsProviderAPI.FormsColumns.FORM_FILE_PATH};
String selection = FormsProviderAPI.FormsColumns.JR_FORM_ID + "=?";
String[] selectionArgs = new String[]{jrFormId};
- String sortOrder = FormsProviderAPI.FormsColumns.JR_VERSION + " DESC LIMIT 1";
Cursor cursor = getContentResolver().query(FormsProviderAPI.FormsColumns.CONTENT_URI,
projection,
@@ -262,42 +257,6 @@ protected long getFormId(String jrFormId) throws CursorIndexOutOfBoundsException
return formId;
}
- private void openNewForm(String jsFormId) {
- toast("No, saved form found.");
- Cursor cursorForm = context.getContentResolver().query(FormsProviderAPI.FormsColumns.CONTENT_URI, null,
- FormsProviderAPI.FormsColumns.JR_FORM_ID + " =?",
- new String[]{jsFormId}, null);
-
-
- if (cursorForm != null && cursorForm.getCount() != 1) {
- //bad data
- //fix the error later
- Toast.makeText(context, R.string.msg_form_not_present, Toast.LENGTH_LONG).show();
- return;
- }
-
- cursorForm.moveToFirst();
- long idFormsTable = Long.parseLong(cursorForm.getString(cursorForm.getColumnIndex(FormsProviderAPI.FormsColumns._ID)));
- Timber.d("Opening new form with _ID%s", idFormsTable);
-
- Uri formUri = ContentUris.withAppendedId(FormsProviderAPI.FormsColumns.CONTENT_URI, idFormsTable);
-
- 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);
-
- }
-
- cursorForm.close();
- }
protected void fillODKForm(String idString) {
try {
@@ -623,46 +582,6 @@ public void onComplete() {
}
- private String createInstanceFolder(FieldSightNotification notification) {
- return null;
- }
-
- @Nullable
- private String getFilePathFromUri(Uri instanceUri) {
-
- String instanceFolderPath = null;
- String uriMimeType = null;
-
- if (instanceUri != null) {
- uriMimeType = getContentResolver().getType(instanceUri);
- }
-
- if (uriMimeType != null
- && uriMimeType.equals(InstanceProviderAPI.InstanceColumns.CONTENT_ITEM_TYPE)) {
- Cursor instance = null;
- try {
- instance = getContentResolver().query(instanceUri,
- null, null, null, null);
- if (instance != null && instance.getCount() == 1) {
- instance.moveToFirst();
- instanceFolderPath = instance
- .getString(instance
- .getColumnIndex(InstanceProviderAPI.InstanceColumns.INSTANCE_FILE_PATH));
- String fileName = FilenameUtils.getName(instanceFolderPath);
- instanceFolderPath = instanceFolderPath.replace(fileName, "");
- }
- } finally {
- if (instance != null) {
- instance.close();
- }
- }
- }
-
-
- return instanceFolderPath;
- }
-
-
private void showErrorDialog(String errorMessage) {
runOnUiThread(new Runnable() {
@Override
@@ -761,43 +680,6 @@ private void loadSavedInstance(String fsInstanceId, String jrFormId) {
}
}
- /**
- * find the form primary key then open the saved instance of that form (if present)
- * other wise open the form blank
- */
- private void handleFlagForm(String fsFormId, String jrFormId, String siteId) {
-
- Uri uri = InstanceProviderAPI.InstanceColumns.CONTENT_URI;
- String selection = InstanceProviderAPI.InstanceColumns.SUBMISSION_URI + " LIKE ?"
- + " AND " + InstanceProviderAPI.InstanceColumns.FS_SITE_ID + " =? ";
- String[] selectionArgs = new String[]{"%/" + fsFormId + "/%", siteId};
-
- Cursor cursorInstanceForm = null;
- try {
- cursorInstanceForm = context.getContentResolver()
- .query(uri, null,
- selection,
- selectionArgs, null);
-
- Timber.i("Found %s INSTANCES", cursorInstanceForm.getCount());
- int count = cursorInstanceForm.getCount();
- if (count >= 1) {
- //todo atm opens the latest saved need to compare timestamp with server submission to open exact instance
- openSavedForm(cursorInstanceForm);
- } else {
- fillODKForm(jrFormId);
- }
- } catch (NullPointerException | CursorIndexOutOfBoundsException e) {
- ToastUtils.showLongToast(getString(R.string.dialog_unexpected_error_title));
- } finally {
- if (cursorInstanceForm != null) {
- cursorInstanceForm.close();
- }
- }
-
- }
-
-
private void openSavedForm(Cursor cursorInstanceForm) {
Toast.makeText(context, "Opening saved form.", Toast.LENGTH_LONG).show();
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/flagform/InstanceRemoteSource.java b/collect_app/src/main/java/org/fieldsight/naxa/flagform/InstanceRemoteSource.java
index 089531321..f836ca25d 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/flagform/InstanceRemoteSource.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/flagform/InstanceRemoteSource.java
@@ -1,20 +1,19 @@
package org.fieldsight.naxa.flagform;
import android.content.ContentValues;
-import android.database.Cursor;
import android.net.Uri;
import android.os.Environment;
-import org.odk.collect.android.application.Collect;
-import org.odk.collect.android.dto.Instance;
-import org.odk.collect.android.provider.InstanceProviderAPI;
import org.fieldsight.naxa.common.FieldSightUserSession;
import org.fieldsight.naxa.common.downloader.RxDownloader;
import org.fieldsight.naxa.data.FieldSightNotification;
+import org.fieldsight.naxa.helpers.FSInstancesDao;
import org.fieldsight.naxa.network.APIEndpoint;
import org.fieldsight.naxa.network.ApiInterface;
import org.fieldsight.naxa.network.ServiceGenerator;
-import org.fieldsight.naxa.helpers.FSInstancesDao;
+import org.odk.collect.android.application.Collect;
+import org.odk.collect.android.dto.Instance;
+import org.odk.collect.android.provider.InstanceProviderAPI;
import java.io.File;
import java.text.SimpleDateFormat;
@@ -113,7 +112,6 @@ private Uri saveInstance(Instance instance) {
private Instance.Builder mapNotificationToInstance(FieldSightNotification notificationFormDetail) {
String siteId = notificationFormDetail.getSiteId() == null ? "0" : notificationFormDetail.getSiteId();//survey form have 0 as siteId
- String fsFormIdProject = notificationFormDetail.getFsFormIdProject();
String formName = notificationFormDetail.getFormName();
String jrFormId = notificationFormDetail.getIdString();
String fsFormId = notificationFormDetail.getFsFormId();
@@ -142,17 +140,6 @@ private String formatFileName(String text) {
return text.replace(" ", "_");
}
- private String getColumnString(Cursor cursor, String columnName) {
- return cursor.getString(cursor.getColumnIndex(columnName));
- }
-
-
- private String getInstanceFolderPath(String formName) {
-
- String time = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.ENGLISH).format(Calendar.getInstance().getTime());
- String instancePath = Collect.INSTANCES_PATH.replace(Environment.getExternalStorageDirectory().toString(), "");
- return instancePath + File.separator + formName + "_" + time;
- }
private String addDateTimeToFileName(String formName) {
String time = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.ENGLISH).format(Calendar.getInstance().getTime());
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/forms/data/local/FieldSightFormsLocalSourcev3.java b/collect_app/src/main/java/org/fieldsight/naxa/forms/data/local/FieldSightFormsLocalSourcev3.java
index 4d39d08f2..f417f0f0e 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/forms/data/local/FieldSightFormsLocalSourcev3.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/forms/data/local/FieldSightFormsLocalSourcev3.java
@@ -11,8 +11,6 @@
import org.fieldsight.naxa.common.FieldSightDatabase;
import org.fieldsight.naxa.stages.data.Stage;
import org.fieldsight.naxa.stages.data.SubStage;
-import org.json.JSONArray;
-import org.json.JSONObject;
import org.odk.collect.android.application.Collect;
import java.util.ArrayList;
@@ -83,31 +81,6 @@ public void onError(Throwable e) {
return mediator;
}
- private Single getStageAndSubStagesAsJSON(List forms, String siteTypeId) {
- return getSortedStages(forms, siteTypeId)
- .map(new Function, JSONArray>() {
- @Override
- public JSONArray apply(List formDetailsv3s) throws Exception {
- JSONArray stages = new JSONArray();
-
- JSONObject stage = new JSONObject();
- JSONArray subStages = new JSONArray();
-
-
- for (FieldsightFormDetailsv3 form : formDetailsv3s) {
- StageSubStage stageAndSubStage = FieldsightFormDetailsv3.getStageAndSubstage(form.getMetaAttributes());
-
-
- }
-
- stages.put(stage);
- stages.put(subStages);
-
- return stages;
- }
- });
- }
-
public MediatorLiveData> getStageForms(String projectId, String siteId, String siteTypeId) {
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/generalforms/data/GeneralFormLocalSource.java b/collect_app/src/main/java/org/fieldsight/naxa/generalforms/data/GeneralFormLocalSource.java
index 3c58080cf..09c044c28 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/generalforms/data/GeneralFormLocalSource.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/generalforms/data/GeneralFormLocalSource.java
@@ -8,22 +8,19 @@
import androidx.lifecycle.MediatorLiveData;
import androidx.lifecycle.Observer;
-import org.odk.collect.android.application.Collect;
import org.fieldsight.naxa.common.BaseLocalDataSource;
import org.fieldsight.naxa.common.FieldSightDatabase;
import org.fieldsight.naxa.previoussubmission.LastSubmissionLocalSource;
import org.fieldsight.naxa.previoussubmission.model.GeneralFormAndSubmission;
import org.fieldsight.naxa.previoussubmission.model.SubmissionDetail;
+import org.odk.collect.android.application.Collect;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.Maybe;
import io.reactivex.Observable;
-import io.reactivex.ObservableTransformer;
-
import io.reactivex.SingleObserver;
-import io.reactivex.SingleTransformer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Function;
@@ -240,25 +237,10 @@ public void updateAll(ArrayList items) {
}
- private ObservableTransformer applySchedulers() {
- return observable -> observable.subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread());
- }
-
- private SingleTransformer applySchedulersSingle() {
- return observable -> observable.subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread());
- }
-
-
public LiveData> getById(String fsFormId) {
return dao.getById(fsFormId);
}
- public void updateLastSubmission(SubmissionDetail formResponse) {
-
- }
-
public Integer getSiteFormCount(String siteId) {
return dao.getSiteFormCount(siteId);
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/generalforms/data/GeneralFormRemoteSource.java b/collect_app/src/main/java/org/fieldsight/naxa/generalforms/data/GeneralFormRemoteSource.java
index ad903b89e..1102be057 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/generalforms/data/GeneralFormRemoteSource.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/generalforms/data/GeneralFormRemoteSource.java
@@ -213,7 +213,7 @@ public void onSuccess(ArrayList generalForms) {
@Override
public void onError(Throwable e) {
- e.printStackTrace();
+ Timber.e(e);
EventBus.getDefault().post(new DataSyncEvent(Constant.DownloadUID.GENERAL_FORMS, EVENT_ERROR));
}
});
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/login/BaseLoginActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/login/BaseLoginActivity.java
index 3b68aee32..9af3477e3 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/login/BaseLoginActivity.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/login/BaseLoginActivity.java
@@ -1,6 +1,5 @@
package org.fieldsight.naxa.login;
-import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/login/LoginActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/login/LoginActivity.java
index b599a3186..53e5f83ca 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/login/LoginActivity.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/login/LoginActivity.java
@@ -15,7 +15,6 @@
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
-import android.widget.RelativeLayout;
import android.widget.Toast;
import com.google.android.gms.common.SignInButton;
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/login/LoginPresenterImpl.java b/collect_app/src/main/java/org/fieldsight/naxa/login/LoginPresenterImpl.java
index 5333e564f..ec2ebd65e 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/login/LoginPresenterImpl.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/login/LoginPresenterImpl.java
@@ -95,10 +95,6 @@ public void googleOauthCredentials(String googleAccessToken, String username) {
}
- private boolean isPasswordValid(String password) {
- return password.length() > 4;
- }
-
@Override
public void onError(String message) {
loginView.showProgress(false);
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/login/model/Site.java b/collect_app/src/main/java/org/fieldsight/naxa/login/model/Site.java
index a816f69f6..11c6677a6 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/login/model/Site.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/login/model/Site.java
@@ -166,15 +166,15 @@ public Site(@NonNull String id, String latitude, String longitude, String identi
}
- private final static String postfix = "fake";
+ private final static String POSTFIX = "fake";
public static String getMockedId() {
- return String.valueOf(System.currentTimeMillis()).concat("-").concat(postfix);
+ return String.valueOf(System.currentTimeMillis()).concat("-").concat(POSTFIX);
}
public static boolean isFakeSiteId(String siteId) {
- return siteId.contains(Site.postfix);
+ return siteId.contains(Site.POSTFIX);
}
public boolean hasSubSites() {
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/login/model/SiteBuilder.java b/collect_app/src/main/java/org/fieldsight/naxa/login/model/SiteBuilder.java
index 82d74fa9e..a230e21d1 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/login/model/SiteBuilder.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/login/model/SiteBuilder.java
@@ -32,7 +32,6 @@ public class SiteBuilder {
private Parcel in;
private List siteDocuments;
private String site;
- private boolean enable_subsites;
public SiteBuilder setId(String id) {
@@ -140,10 +139,7 @@ public SiteBuilder setRegion(String region) {
return this;
}
- public SiteBuilder setEnableStatue(boolean enable_subsites) {
- this.enable_subsites = enable_subsites;
- return this;
- }
+
public SiteBuilder setSites(String site) {
this.site = site;
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/migrate/MigrateFieldSightViewModel.java b/collect_app/src/main/java/org/fieldsight/naxa/migrate/MigrateFieldSightViewModel.java
index 8660b0982..72508128d 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/migrate/MigrateFieldSightViewModel.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/migrate/MigrateFieldSightViewModel.java
@@ -300,7 +300,6 @@ Observable copyFromOldAccount() {
emitter.onComplete();
} catch (Exception ex) {
- ex.printStackTrace();
emitter.onError(ex);
}
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/notificationslist/NotificationListActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/notificationslist/NotificationListActivity.java
index b565b583d..24cbfba07 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/notificationslist/NotificationListActivity.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/notificationslist/NotificationListActivity.java
@@ -31,6 +31,7 @@
import org.fieldsight.naxa.flagform.FlaggedInstanceActivity;
import org.fieldsight.naxa.network.NetworkUtils;
import org.fieldsight.naxa.v3.network.NotificationRemoteSource;
+import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONObject;
import org.odk.collect.android.activities.CollectAbstractActivity;
@@ -154,7 +155,7 @@ public void onRefresh() {
rvNotificationList.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
- public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
+ public void onScrolled(@NotNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int visibleThreshold = 15;
int totalItemCount = rvNotificationList.getLayoutManager().getItemCount();
@@ -171,7 +172,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
});
if (adapter.getItemCount() == 0) {
- getDataFromServer("" + (System.currentTimeMillis() / 1000), older_notification);
+ getDataFromServer(String.valueOf((System.currentTimeMillis() / 1000)), older_notification);
emptyLayout.setVisibility(View.VISIBLE);
tvMessageNodata.setVisibility(View.VISIBLE);
tvMessageNodata.setText("Loading notification please wait");
@@ -193,7 +194,7 @@ private void pullNotificationByDate(String type) {
if (lastUpdatedDate != null) {
String date = lastUpdatedDate.getReceivedDateTime();
- String epochTime = DateTimeUtils.tsToSec8601(date) + "";
+ String epochTime = String.valueOf(DateTimeUtils.tsToSec8601(date));
Timber.i("NotificationListActivity, date = %s, epochTime = %s", date, epochTime);
if (epochTime != null) {
getDataFromServer(epochTime, type);
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/onboarding/DownloadActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/onboarding/DownloadActivity.java
index 35202c9b1..35113243f 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/onboarding/DownloadActivity.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/onboarding/DownloadActivity.java
@@ -6,8 +6,6 @@
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
-import android.view.animation.AnimationUtils;
-import android.view.animation.LayoutAnimationController;
import android.widget.Button;
import androidx.appcompat.widget.Toolbar;
@@ -36,7 +34,6 @@
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
-import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static org.fieldsight.naxa.common.Constant.DownloadUID.ALL_FORMS;
import static org.fieldsight.naxa.common.Constant.DownloadUID.EDU_MATERIALS;
import static org.fieldsight.naxa.common.Constant.DownloadUID.PREV_SUBMISSION;
@@ -70,13 +67,6 @@ public static void start(Activity context, int outOfSyncUid) {
context.startActivity(intent);
}
-
- private static void start(Context context) {
- Intent intent = new Intent(context, DownloadActivity.class);
- intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
- }
-
public static void runAll(Context context) {
Intent intent = new Intent(context, DownloadActivity.class);
intent.putExtra("run_all", true);
@@ -247,18 +237,6 @@ public void onError(Throwable e) {
}
-
- private void runLayoutAnimation(final RecyclerView recyclerView) {
-
- final Context context = recyclerView.getContext();
- final LayoutAnimationController controller =
- AnimationUtils.loadLayoutAnimation(context, R.anim.layout_animation_fall_down);
-
- recyclerView.setLayoutAnimation(controller);
- recyclerView.getAdapter().notifyDataSetChanged();
- recyclerView.scheduleLayoutAnimation();
- }
-
@Override
public LifecycleOwner getLifeCycleOwner() {
return this;
@@ -277,9 +255,6 @@ public void onViewClicked(View view) {
}
}
- protected boolean areCheckedItems() {
- return getCheckedCount() > 0;
- }
protected int getCheckedCount() {
return downloadListAdapter.getSelectedItemsCount();
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/project/ProjectListActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/project/ProjectListActivity.java
index f1ad1f4a3..855368f52 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/project/ProjectListActivity.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/project/ProjectListActivity.java
@@ -4,9 +4,6 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
-import android.transition.Fade;
-import android.transition.Transition;
-import android.transition.TransitionInflater;
import android.util.Pair;
import android.view.Menu;
import android.view.MenuItem;
@@ -28,7 +25,6 @@
import org.fieldsight.collect.android.BuildConfig;
import org.fieldsight.collect.android.R;
-import org.odk.collect.android.application.ForceUpdateChecker;
import org.fieldsight.naxa.BackupActivity;
import org.fieldsight.naxa.common.FieldSightUserSession;
import org.fieldsight.naxa.common.InternetUtils;
@@ -48,6 +44,7 @@
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.odk.collect.android.activities.CollectAbstractActivity;
+import org.odk.collect.android.application.ForceUpdateChecker;
import java.util.ArrayList;
@@ -82,7 +79,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_project_list);
- setupWindowTransition();
ButterKnife.bind(this);
setupToolbar();
setupProjectList();
@@ -248,19 +244,7 @@ public void onItemClick(Project project) {
}
- private void setupWindowTransition() {
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
- Transition slide = TransitionInflater.from(this).inflateTransition(R.transition.slide_top);
- Transition exit = TransitionInflater.from(this).inflateTransition(R.transition.slide_bottom);
-
- Fade fade = new Fade();
- fade.setDuration(1000);
-// getWindow().setEnterTransition(fade);
-// getWindow().setExitTransition(fade);
-
- }
- }
@Override
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/project/data/ProjectSitesRemoteSource.java b/collect_app/src/main/java/org/fieldsight/naxa/project/data/ProjectSitesRemoteSource.java
index ad793c694..fbeb93f6e 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/project/data/ProjectSitesRemoteSource.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/project/data/ProjectSitesRemoteSource.java
@@ -1,7 +1,7 @@
package org.fieldsight.naxa.project.data;
-import org.odk.collect.android.application.Collect;
import org.fieldsight.naxa.common.BaseRemoteDataSource;
+import org.fieldsight.naxa.common.DisposableManager;
import org.fieldsight.naxa.common.GSONInstance;
import org.fieldsight.naxa.common.SharedPreferenceUtils;
import org.fieldsight.naxa.common.event.DataSyncEvent;
@@ -16,11 +16,10 @@
import org.fieldsight.naxa.site.data.SiteRegion;
import org.fieldsight.naxa.site.db.SiteLocalSource;
import org.fieldsight.naxa.site.db.SiteRepository;
-import org.fieldsight.naxa.common.DisposableManager;
import org.fieldsight.naxa.sync.DownloadableItemLocalSource;
import org.greenrobot.eventbus.EventBus;
+import org.odk.collect.android.application.Collect;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -58,65 +57,6 @@ public ProjectSitesRemoteSource() {
}
- private Single> fetchProjectSites() {
- return ServiceGenerator.getRxClient()
- .create(ApiInterface.class)
- .getUser()
- .flatMap((Function>>) meResponse -> {
- if (meResponse.getData() == null || !meResponse.getData().getIsSupervisor()) {
- throw new BadUserException("You have not been assigned as a site supervisor.");
- }
- String user = GSONInstance.getInstance().toJson(meResponse.getData());
- SharedPreferenceUtils.saveToPrefs(Collect.getInstance(), SharedPreferenceUtils.PREF_KEY.USER, user);
-
- return ServiceGenerator.getRxClient().create(ApiInterface.class).getAssignedSites();
- }).flatMapIterable((Function, Iterable>) mySites -> mySites)
- .map(mySites -> {
- siteRepository.saveSitesAsVerified(mySites.getSite(), mySites.getProject());
- return mySites.getProject();
- })
- .toList()
- .map((Function, Set>) projects -> {
- ArrayList uniqueList = new ArrayList<>();
- ArrayList projectIds = new ArrayList<>();
- for (Project project : projects) {
- if (!projectIds.contains(project.getId())) {
- projectIds.add(project.getId());
- uniqueList.add(project);
- }
- }
-
- return new HashSet<>(uniqueList);
- })
- .flattenAsObservable(new Function, Iterable>() {
- @Override
- public Iterable apply(Set projects) throws Exception {
- return projects;
- }
- })
- .flatMap(new Function>() {
- @Override
- public ObservableSource> apply(Project project) throws Exception {
- ProjectLocalSource.getInstance().save(project);
- Observable siteRegionObservable = ServiceGenerator.getRxClient().create(ApiInterface.class)
- .getRegionsByProjectId(project.getId())
- .flatMap(new Function, ObservableSource>() {
- @Override
- public ObservableSource apply(List siteRegions) {
- siteRegions.add(new SiteRegion("", "Unassigned ", ""));
- String value = GSONInstance.getInstance().toJson(siteRegions);
- ProjectLocalSource.getInstance().updateSiteClusters(project.getId(), value);
- return Observable.just(project);
- }
- });
-
- return Observable.concat(siteRegionObservable, Observable.just("demo"));
- }
- })
- .toList()
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread());
- }
private Single> fetchProjectAndSites() {
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/report/ReportActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/report/ReportActivity.java
index e69199943..4b76c18c7 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/report/ReportActivity.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/report/ReportActivity.java
@@ -98,7 +98,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
tvAppVersion.setText(BuildConfig.VERSION_NAME);
tvOsVersion.setText(Build.VERSION.RELEASE);
tvDeviceName.setText(Build.MANUFACTURER);
- new PermissionUtils().requestLocationPermissions(this, new PermissionListener() {
+ new PermissionUtils().requestLocationPermissions(this, new PermissionListener() {
@SuppressLint("MissingPermission")
@Override
public void granted() {
@@ -108,8 +108,8 @@ public void granted() {
public void onSuccess(Location location) {
// Got last known location. In some rare situations this can be null.
if (location != null) {
- tvLat.setText(location.getLatitude() + "");
- tvLng.setText(location.getLongitude() + "");
+ tvLat.setText(String.valueOf(location.getLatitude()));
+ tvLng.setText(String.valueOf(location.getLongitude()));
}
}
});
@@ -122,28 +122,28 @@ public void denied() {
});
-
}
private String checkEmptyWithFallback(View v, String fallback) {
CharSequence data = "";
- if(v instanceof TextView) {
- data = ((TextView)v).getText();
- }else if(v instanceof EditText){
- data = ((EditText)v).getText();
- }else if(v instanceof Spinner){
- Spinner spnr = (Spinner)v;
+ if (v instanceof TextView) {
+ data = ((TextView) v).getText();
+ } else if (v instanceof EditText) {
+ data = ((EditText) v).getText();
+ } else if (v instanceof Spinner) {
+ Spinner spnr = (Spinner) v;
data = spnr.getSelectedItemPosition() == 0 ? fallback : spnr.getSelectedItem().toString();
}
- return TextUtils.isEmpty(data)? fallback : data.toString();
+ return TextUtils.isEmpty(data) ? fallback : data.toString();
}
+
@OnClick(R.id.btn_report)
void submitReport() {
- if(isSubmitting) {
+ if (isSubmitting) {
Toast.makeText(getApplicationContext(), "Report form is submitting please wait", Toast.LENGTH_SHORT).show();
return;
}
- if(chkbxAgree.isChecked()) {
+ if (chkbxAgree.isChecked()) {
isSubmitting = true;
String deviceId = checkEmptyWithFallback(tvDeviceId, "0");
String deviceName = checkEmptyWithFallback(tvDeviceName, "");
@@ -163,7 +163,7 @@ void submitReport() {
@Override
public void onNext(ResponseBody response) {
try {
- if(response != null) {
+ if (response != null) {
String reply = response.string();
JSONObject replyJSON = new JSONObject(reply);
Toast.makeText(getApplicationContext(), replyJSON.optString("message"), Toast.LENGTH_SHORT).show();
@@ -191,7 +191,7 @@ public void onComplete() {
}
});
showPrgressDialog();
- }else {
+ } else {
Toast.makeText(this, "Please select I agree", Toast.LENGTH_SHORT).show();
}
}
@@ -199,29 +199,30 @@ public void onComplete() {
@Override
protected void onDestroy() {
super.onDestroy();
- if(observer != null && !observer.isDisposed()) {
+ if (observer != null && !observer.isDisposed()) {
observer.dispose();
}
}
- ProgressDialog pd ;
+ ProgressDialog pd;
+
void showPrgressDialog() {
- if(pd == null) {
- pd = new ProgressDialog(this);
- }
- pd.setMessage("Submitting your report please wait");
- pd.show();
+ if (pd == null) {
+ pd = new ProgressDialog(this);
+ }
+ pd.setMessage("Submitting your report please wait");
+ pd.show();
}
void hideProgressDialog() {
- if(pd != null) {
+ if (pd != null) {
pd.hide();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if(item.getItemId() == android.R.id.home) {
+ if (item.getItemId() == android.R.id.home) {
finish();
return true;
}
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/scheduled/ScheduledFormsAdapter.java b/collect_app/src/main/java/org/fieldsight/naxa/scheduled/ScheduledFormsAdapter.java
index abe1a1c06..d0dd9eb4c 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/scheduled/ScheduledFormsAdapter.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/scheduled/ScheduledFormsAdapter.java
@@ -76,7 +76,6 @@ private void setSubmissionText(ScheduledFormsAdapter.ViewHolder viewHolder, Subm
String submittedBy = "";
String submissionStatus = "";
String scheduleType = "";
- String formCreatedAt = "";
Context context = viewHolder.cardView.getContext();
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/scheduled/data/ScheduledFormsFragment.java b/collect_app/src/main/java/org/fieldsight/naxa/scheduled/data/ScheduledFormsFragment.java
index 936876642..5cf2740a6 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/scheduled/data/ScheduledFormsFragment.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/scheduled/data/ScheduledFormsFragment.java
@@ -112,7 +112,6 @@ public void onChanged(@Nullable List scheduledFormAn
private void setupListAdapter() {
- LinearLayoutManager manager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setItemAnimator(new DefaultItemAnimator());
scheduledFormsAdapter = new ScheduledFormsAdapter(new ArrayList<>(0), this);
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/site/ProjectDashboardActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/site/ProjectDashboardActivity.java
index b495f493e..46bfe009e 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/site/ProjectDashboardActivity.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/site/ProjectDashboardActivity.java
@@ -1,7 +1,6 @@
package org.fieldsight.naxa.site;
import android.app.Activity;
-import android.app.ActivityOptions;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -66,7 +65,6 @@
import org.fieldsight.naxa.login.model.User;
import org.fieldsight.naxa.notificationslist.NotificationListActivity;
import org.fieldsight.naxa.profile.UserActivity;
-
import org.fieldsight.naxa.project.TermsLabels;
import org.fieldsight.naxa.site.db.SiteLocalSource;
import org.fieldsight.naxa.v3.network.SyncActivity;
@@ -122,7 +120,6 @@ public static void start(Context context, Project project) {
@SafeVarargs
public static void start(Activity context, Project project, Pair... pairs) {
- ActivityOptions activityOptions = null;
Intent intent = new Intent(context, ProjectDashboardActivity.class);
intent.putExtra(EXTRA_OBJECT, project);
context.startActivity(intent);
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/site/SiteDashboardFragment.java b/collect_app/src/main/java/org/fieldsight/naxa/site/SiteDashboardFragment.java
index d72b39428..8fecfa097 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/site/SiteDashboardFragment.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/site/SiteDashboardFragment.java
@@ -22,7 +22,6 @@
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
-import androidx.lifecycle.LiveData;
import com.google.common.primitives.Longs;
@@ -568,7 +567,7 @@ private ArrayList getNotUploadedFormForSite(String siteId) {
private void toForms() {
- FieldSightFormListFragment fragment = FieldSightFormListFragment.newInstance(Constant.FormType.GENERAl, loadedSite);
+ FieldSightFormListFragment fragment = FieldSightFormListFragment.newInstance(Constant.FormType.GENERAL, loadedSite);
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setCustomAnimations(FRAGMENT_ENTER_ANIMATION, FRAGMENT_EXIT_ANIMATION, FRAGMENT_POP_ENTER_ANIMATION, FRAGMENT_POP_EXIT_ANIMATION);
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/site/SiteListAdapter.java b/collect_app/src/main/java/org/fieldsight/naxa/site/SiteListAdapter.java
index 32ef37711..2662eb8b4 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/site/SiteListAdapter.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/site/SiteListAdapter.java
@@ -81,7 +81,6 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
switch (holder.getItemViewType()) {
case VIEW_TYPE_SURVEY_FORM:
- SurveyViewHolder surveyViewHolder = (SurveyViewHolder) holder;
break;
default:
SiteViewHolder siteViewHolder = (SiteViewHolder) holder;
@@ -235,7 +234,6 @@ public void onClick(View v) {
private void applyOffilineSiteTag(SiteViewHolder holder, Site siteLocationPojo) {
boolean isChecked = selectedItems.get(holder.getAdapterPosition(), false);
boolean isUnVerifiedSite = siteLocationPojo.getIsSiteVerified() == Constant.SiteStatus.IS_OFFLINE;
- boolean isVerifiedSite = siteLocationPojo.getIsSiteVerified() == Constant.SiteStatus.IS_ONLINE;
boolean isEditedSite = siteLocationPojo.getIsSiteVerified() == Constant.SiteStatus.IS_EDITED;
holder.offlinetag.setVisibility(View.GONE);
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/site/SiteListFragment.java b/collect_app/src/main/java/org/fieldsight/naxa/site/SiteListFragment.java
index 24a020ba1..64fac0408 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/site/SiteListFragment.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/site/SiteListFragment.java
@@ -28,7 +28,6 @@
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.common.primitives.Longs;
-import com.google.gson.reflect.TypeToken;
import org.fieldsight.collect.android.R;
import org.fieldsight.naxa.common.Constant;
@@ -41,7 +40,6 @@
import org.fieldsight.naxa.login.model.Project;
import org.fieldsight.naxa.login.model.Site;
import org.fieldsight.naxa.project.TermsLabels;
-import org.fieldsight.naxa.site.data.SiteRegion;
import org.fieldsight.naxa.site.db.SiteLocalSource;
import org.fieldsight.naxa.site.db.SiteRemoteSource;
import org.fieldsight.naxa.v3.network.Region;
@@ -53,7 +51,6 @@
import org.odk.collect.android.provider.InstanceProviderAPI;
import org.odk.collect.android.utilities.ThemeUtils;
-import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
@@ -80,7 +77,6 @@ public class SiteListFragment extends Fragment implements SiteListAdapter.SiteLi
private Unbinder unbinder;
private SiteListAdapter siteListAdapter;
private LiveData> allSitesLiveData;
- private LiveData> offlineSitesLiveData;
private BottomSheetDialog bottomSheetDialog;
private ActionMode actionMode;
@@ -181,36 +177,15 @@ private void setupRecycleView() {
}
- private void assignFilterToList(FilterOption.FilterType type) {
- LiveData> source;
-
- switch (type) {
- case OFFLINE_SITES:
- source = offlineSitesLiveData;
- break;
- case ALL_SITES:
- default:
- source = allSitesLiveData;
- break;
- }
- source.observe(this, sites -> {
- siteListAdapter.updateList(sites);
- });
-
- }
-
private void collectFilterAndApply(ArrayList sortList) {
- String site = "", selectedRegion = "0", regionLabel = "";
+ String selectedRegion = "0";
for (FilterOption filterOption : sortList) {
switch (filterOption.getType()) {
- case SITE:
- site = filterOption.getSelectionId();
- break;
case SELECTED_REGION:
selectedRegion = filterOption.getSelectionId();
- regionLabel = filterOption.getSelectionLabel();
+
break;
}
}
@@ -292,8 +267,6 @@ public void onItemClicked(FilterDialogAdapter.ViewHolderText holder, int positio
public MutableLiveData> getFilterOptionForSites() {
- Type type = new TypeToken>() {
- }.getType();
List siteRegions;
siteRegions = loadedProject.getRegionList();
@@ -347,11 +320,6 @@ public void onError(Throwable e) {
}
- private FilterOption.FilterType getSelectedFilter() {
-
- return FilterOption.FilterType.ALL_SITES;
-
- }
@Override
public boolean onOptionsItemSelected(MenuItem item) {
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/site/db/SiteLocalSource.java b/collect_app/src/main/java/org/fieldsight/naxa/site/db/SiteLocalSource.java
index 34569103d..89e992e92 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/site/db/SiteLocalSource.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/site/db/SiteLocalSource.java
@@ -127,14 +127,14 @@ public void updateAll(ArrayList items) {
public void setSiteAsNotFinalized(String siteId) {
AsyncTask.execute(() -> {
- long i = dao.updateSiteStatus(siteId, Constant.SiteStatus.IS_OFFLINE);
+ dao.updateSiteStatus(siteId, Constant.SiteStatus.IS_OFFLINE);
});
}
public void setSiteAsFinalized(String siteId) {
AsyncTask.execute(() -> {
- long i = dao.updateSiteStatus(siteId, Constant.SiteStatus.IS_FINALIZED);
+ dao.updateSiteStatus(siteId, Constant.SiteStatus.IS_FINALIZED);
});
}
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/stages/StageListFragment.java b/collect_app/src/main/java/org/fieldsight/naxa/stages/StageListFragment.java
index 6a6b21099..c01b232d6 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/stages/StageListFragment.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/stages/StageListFragment.java
@@ -13,7 +13,6 @@
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
-import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/submissions/MultiViewAdapter.java b/collect_app/src/main/java/org/fieldsight/naxa/submissions/MultiViewAdapter.java
index 89928b18a..21595e4b0 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/submissions/MultiViewAdapter.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/submissions/MultiViewAdapter.java
@@ -1,7 +1,5 @@
package org.fieldsight.naxa.submissions;
-import android.content.Context;
-
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.View;
@@ -116,10 +114,9 @@ public ViewModel getItem(int position) {
}
@Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ public void onBindViewHolder(@NotNull RecyclerView.ViewHolder holder, int position) {
final ViewModel result = listOfItems.get(position);
- Context context = holder.itemView.getContext();
switch (getItemViewType(position)) {
case TEXT_DESC:
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/submissions/PaginationAdapter.java b/collect_app/src/main/java/org/fieldsight/naxa/submissions/PaginationAdapter.java
index d995b685e..9756eaa87 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/submissions/PaginationAdapter.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/submissions/PaginationAdapter.java
@@ -7,7 +7,6 @@
import android.widget.TextView;
import androidx.annotation.NonNull;
-import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import org.fieldsight.collect.android.R;
@@ -204,7 +203,6 @@ protected class FormVH extends RecyclerView.ViewHolder {
public FormVH(View itemView) {
super(itemView);
- CardView rootLayout = itemView.findViewById(R.id.card_view_item_recycler_view);
tvTitle = itemView.findViewById(R.id.item_text);
tvSubmissionDateTime = itemView.findViewById(R.id.tv_item_submitted_by);
}
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/submissions/PreviousSubmissionListActivity.java b/collect_app/src/main/java/org/fieldsight/naxa/submissions/PreviousSubmissionListActivity.java
index 9df1b1de4..5728cf5bb 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/submissions/PreviousSubmissionListActivity.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/submissions/PreviousSubmissionListActivity.java
@@ -42,13 +42,12 @@ public class PreviousSubmissionListActivity extends CollectAbstractActivity impl
private LinearLayoutManager linearLayoutManager;
private RecyclerView listFormHistory;
private PaginationAdapter adapter;
- private TextView tvNoData;
ProgressBar progressBar;
- private boolean isLoading = false;
+ private boolean isLoading ;
- private boolean isLastPage = false;
+ private boolean isLastPage ;
private String urlFirstPage;
private String urlNextPage;
diff --git a/collect_app/src/main/java/org/fieldsight/naxa/v3/network/SyncLocalSource3.java b/collect_app/src/main/java/org/fieldsight/naxa/v3/network/SyncLocalSource3.java
index d7673689b..3bdb5c3ae 100644
--- a/collect_app/src/main/java/org/fieldsight/naxa/v3/network/SyncLocalSource3.java
+++ b/collect_app/src/main/java/org/fieldsight/naxa/v3/network/SyncLocalSource3.java
@@ -57,17 +57,17 @@ public void save(SyncStat... items) {
}
public void markAsQueued(String projectId, int type) {
- SyncStat syncStat = new SyncStat(projectId, type + "", "", false, Constant.DownloadStatus.QUEUED, System.currentTimeMillis());
+ SyncStat syncStat = new SyncStat(projectId, String.valueOf(type) , "", false, Constant.DownloadStatus.QUEUED, System.currentTimeMillis());
save(syncStat);
}
public void markAsFailed(String projectId, int type, String failedUrl) {
- SyncStat syncStat = new SyncStat(projectId, type + "", failedUrl, false, Constant.DownloadStatus.FAILED, System.currentTimeMillis());
+ SyncStat syncStat = new SyncStat(projectId, String.valueOf(type), failedUrl, false, Constant.DownloadStatus.FAILED, System.currentTimeMillis());
save(syncStat);
}
public void markAsCompleted(String projectId, int type) {
- SyncStat syncStat = new SyncStat(projectId, type + "", "", false, Constant.DownloadStatus.COMPLETED, System.currentTimeMillis());
+ SyncStat syncStat = new SyncStat(projectId, String.valueOf(type), "", false, Constant.DownloadStatus.COMPLETED, System.currentTimeMillis());
save(syncStat);
}
@@ -98,7 +98,7 @@ public Single getFailedUrls(String projectId, int type) {
}
public void updateDownloadProgress(String projectId, int progress, int totalFormsInProject) {
- SyncStat syncStat = new SyncStat(projectId, 1 + "", "", false, Constant.DownloadStatus.RUNNING, System.currentTimeMillis());
+ SyncStat syncStat = new SyncStat(projectId, String.valueOf(1) , "", false, Constant.DownloadStatus.RUNNING, System.currentTimeMillis());
syncStat.setProgress(progress);
syncStat.setTotal(totalFormsInProject);
save(syncStat);
diff --git a/collect_app/src/main/java/org/odk/collect/android/upload/UploadAuthRequestedException.java b/collect_app/src/main/java/org/odk/collect/android/upload/UploadAuthRequestedException.java
index a4d93aeb8..888b27a5d 100644
--- a/collect_app/src/main/java/org/odk/collect/android/upload/UploadAuthRequestedException.java
+++ b/collect_app/src/main/java/org/odk/collect/android/upload/UploadAuthRequestedException.java
@@ -16,8 +16,6 @@
import android.net.Uri;
-import org.odk.collect.android.tasks.InstanceUploaderTask;
-
/**
* Thrown to indicate that the server an upload attempt was made to is requesting authentication.
* This may lead to a re-try attempt if the upload was triggered manually by the user (as opposed to
@@ -28,7 +26,7 @@ public class UploadAuthRequestedException extends UploadException {
* The URI for the server that requested authentication. This URI may not match the server
* specified in the app settings or the blank form because there could have been a redirect.
*
- * See also {@link InstanceUploaderTask.Outcome}
+ *
*/
private final Uri authRequestingServer;
diff --git a/collect_app/src/main/java/org/odk/collect/android/utilities/FileUtils.java b/collect_app/src/main/java/org/odk/collect/android/utilities/FileUtils.java
index 3b44ad698..e89fe7441 100644
--- a/collect_app/src/main/java/org/odk/collect/android/utilities/FileUtils.java
+++ b/collect_app/src/main/java/org/odk/collect/android/utilities/FileUtils.java
@@ -623,7 +623,7 @@ private static boolean isSpace(String s) {
if (s == null) {
return true;
}
- for (int i = 0, len = s.length(); i < len; ++i) {
+ for (int i = 0; i < s.length(); ++i) {
if (!Character.isWhitespace(s.charAt(i))) {
return false;
}
@@ -721,7 +721,7 @@ private static boolean copyOrMoveDir(final File srcDir,
return true;
}
}
- if (!createOrExistsDir(destDir)){
+ if (!createOrExistsDir(destDir)) {
return false;
}
File[] files = srcDir.listFiles();
@@ -734,7 +734,7 @@ private static boolean copyOrMoveDir(final File srcDir,
return false;
}
} else if (file.isDirectory()) {
- if (!copyOrMoveDir(file, oneDestFile, listener, isMove)){
+ if (!copyOrMoveDir(file, oneDestFile, listener, isMove)) {
return false;
}
}
@@ -864,7 +864,7 @@ public static boolean deleteFilesInDirWithFilter(final File dir, final FileFilte
return true;
}
// dir isn't a directory then return false
- if (!dir.isDirectory()){
+ if (!dir.isDirectory()) {
return false;
}
File[] files = dir.listFiles();
@@ -872,7 +872,7 @@ public static boolean deleteFilesInDirWithFilter(final File dir, final FileFilte
for (File file : files) {
if (filter.accept(file)) {
if (file.isFile()) {
- if (!file.delete()){
+ if (!file.delete()) {
return false;
}
} else if (file.isDirectory()) {
diff --git a/collect_app/src/main/java/org/odk/collect/android/utilities/SoftKeyboardUtils.java b/collect_app/src/main/java/org/odk/collect/android/utilities/SoftKeyboardUtils.java
index f7a6f6c0d..225c3303e 100644
--- a/collect_app/src/main/java/org/odk/collect/android/utilities/SoftKeyboardUtils.java
+++ b/collect_app/src/main/java/org/odk/collect/android/utilities/SoftKeyboardUtils.java
@@ -23,7 +23,6 @@
import androidx.annotation.NonNull;
import org.odk.collect.android.application.Collect;
-import org.odk.collect.android.logic.FormController;
public class SoftKeyboardUtils {
diff --git a/config/pmd-ruleset.xml b/config/pmd-ruleset.xml
index f882fd481..0c2a2e443 100644
--- a/config/pmd-ruleset.xml
+++ b/config/pmd-ruleset.xml
@@ -28,97 +28,99 @@
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+