Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/res/values-ti/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
<string name="connect_progress_status">%d ናይ %d ምብፃሕ ወዲእካ ኣለኻ።</string>
<string name="connect_progress_warning_ended">እቲ ስራሕ ተዛዚሙ ኣሎ። ንተወሳኺ ስራሕ ዝኾነ ምዕባለ ኣይትረክብን ኢኻ።</string>
<string name="connect_progress_warning_not_started">ነቲ ገምጋም ሓሊፍካ ንምቕራብ ድሉው ኢኻ። ንኽትቅጽል ኩነታት ስራሕ ርአ።</string>
<string name="connect_progress_ready_for_transition_to_delivery">You have passed the assessment and are ready to deliver. View job status to proceed.</string>
<string name="connect_progress_ready_for_transition_to_delivery">ነቲ ገምጋም ሓሊፍካ ንምቕራብ ድሉው ኢኻ። ንኽትቅጽል ኩነታት ስራሕ ርአ።</string>
<string name="connect_progress_warning_max_reached_single">ዝለዓለ ቁፅሪ ምብፃሕ ፈፂምካ ኣለኻ። ንተወሳኺ ስራሕ ዝኾነ ምዕባለ ኣይትረክብን ኢኻ።</string>
<string name="connect_progress_warning_daily_max_reached_single">ንሎሚ ዝለዓለ ቁፅሪ ምብፃሕ በፂሕኩም ኣለኹም። ንተወሳኺ ስራሕ ዝኾነ ምዕባለ ኣይትረክብን ኢኻ።</string>
<string name="connect_progress_warning_max_reached_multi">ን %s ዝለዓለ ቁፅሪ ምብፃሕ በፂሕካ ኣለኻ። </string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import android.view.ViewTreeObserver;
import android.widget.TextView;

import androidx.annotation.ColorRes;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
Expand Down Expand Up @@ -101,18 +103,35 @@ private void setupConnectJobTile() {
}

private void updateConnectJobMessage() {
String warningText = null;
String messageText = null;
String appId = CommCareApplication.instance().getCurrentApp().getUniqueId();
ConnectAppRecord record = ConnectJobUtils.getAppRecord(activity, appId);
ConnectJobRecord job = activity.getActiveJob();

if (job != null && record != null) {
warningText = job.getWarningMessages(activity);
messageText = job.getCardMessageText(activity);
}

connectMessageCard.setVisibility(warningText == null ? View.GONE : View.VISIBLE);
if (warningText != null) {
TextView tv = connectMessageCard.findViewById(R.id.tvConnectMessage);
tv.setText(warningText);
if (messageText != null) {
@ColorRes int textColorRes;
@ColorRes int backgroundColorRes;

if (job.readyToTransitionToDelivery()) {
textColorRes = R.color.connect_green;
backgroundColorRes = R.color.connect_light_green;
} else {
textColorRes = R.color.connect_warning_color;
backgroundColorRes = R.color.connect_light_orange_color;
}

TextView textView = connectMessageCard.findViewById(R.id.tvConnectMessage);
textView.setText(messageText);
textView.setTextColor(ContextCompat.getColor(activity, textColorRes));

connectMessageCard.setCardBackgroundColor(ContextCompat.getColor(activity, backgroundColorRes));
connectMessageCard.setVisibility(View.VISIBLE);
} else {
connectMessageCard.setVisibility(View.GONE);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.commcare.android.database.connect.models;

import static org.commcare.connect.ConnectConstants.STATUS_APPROVED;

import android.content.Context;
import android.text.TextUtils;

Expand Down Expand Up @@ -80,8 +78,8 @@ public class ConnectJobRecord extends Persisted implements Serializable {
public static final String META_PAYMENT_UNIT = "payment_unit";
public static final String META_MAX_VISITS = "max_visits";

private static final String WORKING_HOURS_SOURCE_FORMAT ="HH:mm:ss";
private static final String WORKING_HOURS_TARGET_FORMAT ="h:mm a";
private static final String WORKING_HOURS_SOURCE_FORMAT = "HH:mm:ss";
private static final String WORKING_HOURS_TARGET_FORMAT = "h:mm a";
private static final String WORKING_HOURS_PATTERN = "%s - %s";

public static final String META_USER_SUSPENDED = "is_user_suspended";
Expand Down Expand Up @@ -186,7 +184,7 @@ public ConnectJobRecord() {
dailyFinishTime = "";
}

public static ConnectJobRecord corruptJobFromJson(JSONObject json)throws JSONException{
public static ConnectJobRecord corruptJobFromJson(JSONObject json) throws JSONException {
ConnectJobRecord job = new ConnectJobRecord();
job.title = json.has(META_NAME) ? json.getString(META_NAME) : "";
job.description = json.has(META_DESCRIPTION) ? json.getString(META_DESCRIPTION) : "";
Expand Down Expand Up @@ -238,7 +236,7 @@ public static ConnectJobRecord fromJson(JSONObject json) throws JSONException {
job.paymentUnits = new ArrayList<>();
for (int i = 0; i < unitsJson.length(); i++) {
ConnectPaymentUnitRecord payment = ConnectPaymentUnitRecord.fromJson(unitsJson.getJSONObject(i), job.getJobId());
if(payment != null) {
if (payment != null) {
job.paymentUnits.add(payment);
}
}
Expand Down Expand Up @@ -352,11 +350,18 @@ public void setProjectEndDate(Date date) {
public int getPaymentAccrued() {
return paymentAccrued == null || paymentAccrued.isEmpty() ? 0 : Integer.parseInt(paymentAccrued);
}

public int getLearningPercentComplete() {
return numLearningModules > 0 ? (100 * learningModulesCompleted / numLearningModules) : 100;
}
public String getDailyStartTime() { return dailyStartTime; }
public String getDailyFinishTime() { return dailyFinishTime; }

public String getDailyStartTime() {
return dailyStartTime;
}

public String getDailyFinishTime() {
return dailyFinishTime;
}

public void setPaymentAccrued(int paymentAccrued) {
this.paymentAccrued = Integer.toString(paymentAccrued);
Expand Down Expand Up @@ -567,7 +572,7 @@ public int numberOfDeliveriesToday() {
int dailyVisitCount = 0;
Date today = new Date();
for (ConnectJobDeliveryRecord record : deliveries) {
if(DateUtils.dateDiff(today, record.getDate()) == 0) {
if (DateUtils.dateDiff(today, record.getDate()) == 0) {
dailyVisitCount++;
}
}
Expand All @@ -588,7 +593,7 @@ public HashMap<String, Integer> getDeliveryCountsPerPaymentUnit(boolean todayOnl
HashMap<String, Integer> paymentCounts = new HashMap<>();
for (int i = 0; i < deliveries.size(); i++) {
ConnectJobDeliveryRecord delivery = deliveries.get(i);
if(!todayOnly || DateUtils.dateDiff(new Date(), delivery.getDate()) == 0) {
if (!todayOnly || DateUtils.dateDiff(new Date(), delivery.getDate()) == 0) {
int oldCount = 0;
if (paymentCounts.containsKey(delivery.getSlug())) {
oldCount = paymentCounts.get(delivery.getSlug());
Expand All @@ -610,7 +615,7 @@ public boolean readyToTransitionToDelivery() {
}

@Nullable
public String getWarningMessages(Context context) {
public String getCardMessageText(Context context) {
if (isFinished()) {
return context.getString(R.string.connect_progress_warning_ended);
} else if (getIsUserSuspended()) {
Expand Down Expand Up @@ -697,7 +702,7 @@ public static ConnectJobRecord fromV10(ConnectJobRecordV10 oldRecord) {
newRecord.dateClaimed = oldRecord.getDateClaimed();
newRecord.projectStartDate = oldRecord.getProjectStartDate();
newRecord.isActive = oldRecord.getIsActive();
newRecord.isUserSuspended= oldRecord.getIsUserSuspended();
newRecord.isUserSuspended = oldRecord.getIsUserSuspended();
newRecord.dailyStartTime = "";
newRecord.dailyFinishTime = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
Expand Down Expand Up @@ -61,7 +60,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
setupRefreshAndConfirmationActions();

updateLastUpdatedText(job.getLastDeliveryUpdate());
updateWarningMessage();
updateCardMessage();
updatePaymentConfirmationTile(false);

return binding.getRoot();
Expand Down Expand Up @@ -103,9 +102,12 @@ public void onTabSelected(TabLayout.Tab tab) {
}

@Override
public void onTabUnselected(TabLayout.Tab tab) {}
public void onTabUnselected(TabLayout.Tab tab) {
}

@Override
public void onTabReselected(TabLayout.Tab tab) {}
public void onTabReselected(TabLayout.Tab tab) {
}
});
}

Expand All @@ -114,7 +116,7 @@ public void refresh() {
ConnectJobHelper.INSTANCE.updateDeliveryProgress(getContext(), job, success -> {
if (success) {
updateLastUpdatedText(new Date());
updateWarningMessage();
updateCardMessage();
updatePaymentConfirmationTile(false);
viewPagerAdapter.refresh();
}
Expand All @@ -140,7 +142,7 @@ private void setupRefreshAndConfirmationActions() {
}

private void setupJobCard(ConnectJobRecord job) {
ViewJobCardBinding jobCard =binding.viewJobCard;
ViewJobCardBinding jobCard = binding.viewJobCard;
jobCard.tvViewMore.setOnClickListener(v -> Navigation.findNavController(v)
.navigate(ConnectDeliveryProgressFragmentDirections.actionConnectJobDeliveryProgressFragmentToConnectJobDetailBottomSheetDialogFragment()));

Expand Down Expand Up @@ -173,11 +175,14 @@ public void onDestroyView() {
binding = null;
}

private void updateWarningMessage() {
String warningText = job.getWarningMessages(requireContext());
binding.cvConnectMessage.setVisibility(warningText == null ? View.GONE : View.VISIBLE);
if (warningText != null) {
binding.tvConnectMessage.setText(warningText);
private void updateCardMessage() {
String messageText = job.getCardMessageText(requireContext());

if (messageText != null) {
binding.tvConnectMessage.setText(messageText);
binding.cvConnectMessage.setVisibility(View.VISIBLE);
} else {
binding.cvConnectMessage.setVisibility(View.GONE);
}
}

Expand Down
Loading