Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Commit

Permalink
Resovles bestpractices violation (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
konishon committed Oct 15, 2019
1 parent e4aab42 commit ff84172
Show file tree
Hide file tree
Showing 41 changed files with 189 additions and 529 deletions.
2 changes: 1 addition & 1 deletion collect_app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<activity android:name="org.fieldsight.naxa.educational.EducationalMaterialActivity" />
<activity android:name="org.fieldsight.naxa.project.AppUpdateActivity" />
<activity android:name="org.fieldsight.naxa.educational.EduMat_ViewTextTitleDetailsActivity" />
<activity android:name="org.fieldsight.naxa.educational.EduMat_ViewImageDetailsActivity" />
<activity android:name="org.fieldsight.naxa.educational.EduMatImageDetailsActivity" />
<activity android:name="org.fieldsight.naxa.educational.EduMat_ViewVideoDetailsActivity" />
<activity android:name="org.fieldsight.naxa.FSInstanceUploaderListActivity" />
<activity android:name="org.fieldsight.naxa.FSInstanceChooserList" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -226,10 +226,6 @@ private void parseNotificationData(Map<String, String> 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");
}
Expand Down Expand Up @@ -260,7 +256,7 @@ private void parseNotificationData(Map<String, String> notificationData) {


public static int getID() {
return notificationId.incrementAndGet();
return NOTIFICATION_ID.incrementAndGet();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -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;
}

Expand All @@ -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;
}
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -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);

Expand All @@ -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)
Expand All @@ -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);
Expand All @@ -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");
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ public ObservableSource<Uri> apply(String s) {

private Single<String> 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);
}


Expand All @@ -103,7 +101,7 @@ public void getODKForm(String formName, String fsSubmissionId, String jrFormId,

}

private Single<String> getODKForm(String fsFormId, String siteId, String formName, String fsFormSubmissionId, String jrFormId) {
private Single<String> getODKForm(String formName, String fsFormSubmissionId, String jrFormId) {


return Single.create(emitter -> {
Expand Down
Loading

0 comments on commit ff84172

Please sign in to comment.