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
1 change: 1 addition & 0 deletions app/res/menu/menu_connect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
android:id="@+id/action_credential"
android:icon="@drawable/ic_credential"
android:title="@string/credential"
android:visible="false"
app:showAsAction="always" />
<item
android:id="@+id/action_sync"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
Expand All @@ -14,12 +17,16 @@
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import androidx.core.view.MenuHost;
import androidx.core.view.MenuProvider;
import androidx.lifecycle.Lifecycle;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import org.commcare.android.database.connect.models.ConnectJobDeliveryFlagRecord;
import org.commcare.android.database.connect.models.ConnectJobDeliveryRecord;
import org.commcare.connect.ConnectDateUtils;
import org.commcare.connect.ConnectJobHelper;
import org.commcare.dalvik.R;
import org.commcare.dalvik.databinding.FragmentConnectDeliveryListBinding;

Expand Down Expand Up @@ -49,9 +56,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
binding = FragmentConnectDeliveryListBinding.inflate(inflater, container, false);
unitName = ConnectDeliveryListFragmentArgs.fromBundle(getArguments()).getUnitId();
requireActivity().setTitle(getString(R.string.connect_visit_type_title, unitName));

setupRecyclerView();
setupFilterControls();
setupMenuProvider();
return binding.getRoot();
}

Expand Down Expand Up @@ -95,6 +102,32 @@ private int getFilterCardId(String filter) {
};
}

private void setupMenuProvider() {
MenuHost host = requireActivity();
host.addMenuProvider(new MenuProvider() {
@Override
public void onCreateMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
}

@Override
public boolean onMenuItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.action_sync) {
refreshData();
return true;
}
return false;
}
}, getViewLifecycleOwner(), Lifecycle.State.RESUMED);
}

private void refreshData() {
ConnectJobHelper.INSTANCE.updateDeliveryProgress(getContext(), job, success -> {
if (success) {
adapter.updateDeliveries(getFilteredDeliveries());
}
});
}

private void setFilterHighlight(CardView card, TextView label, boolean selected) {
int bgColor = getResources().getColor(selected ? R.color.connect_blue_color : R.color.connect_blue_color_10);
int textColor = getResources().getColor(selected ? android.R.color.white : R.color.connect_blue_color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private void updateProgressViews(int percent, boolean hideProgress) {
viewBinding.connectLearningProgressBar.setVisibility(visibility);
viewBinding.connectLearningProgressText.setVisibility(visibility);
viewBinding.connectLearnProgressBarTextContainer.setVisibility(visibility);
viewBinding.learningCard.setVisibility(visibility);

if (!hideProgress) {
viewBinding.connectLearningProgressBar.setProgress(percent);
Expand Down Expand Up @@ -181,7 +182,6 @@ private void updateButtons(ConnectJobRecord job, boolean complete, boolean passe
CommCareApplication.instance().closeUserSession();
ConnectAppUtils.INSTANCE.launchApp(getActivity(), true, job.getLearnAppInfo().getAppId());
});
return;
} else {
buttonText = getString(R.string.connect_downloading_learn);
navDirections =
Expand Down Expand Up @@ -243,9 +243,15 @@ private void populateJobCard(ConnectJobRecord job) {
boolean showHours = hours != null;
jobCard.tvJobTime.setVisibility(showHours ? View.VISIBLE : View.GONE);
jobCard.tvDailyVisitTitle.setVisibility(showHours ? View.VISIBLE : View.GONE);
jobCard.tvViewMore.setOnClickListener(this::navigateToJobDetailBottomSheet);

if (showHours) {
jobCard.tvJobTime.setText(hours);
}
}

private void navigateToJobDetailBottomSheet(View view) {
Navigation.findNavController(view).navigate(
ConnectLearningProgressFragmentDirections.actionConnectJobLearningProgressFragmentToConnectJobDetailBottomSheetDialogFragment());
}
Comment on lines +253 to +256
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make sure to format this, seems a bit weird here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its formatted tried

}