Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AC-794 Notify users when active visits or formlist pages are empty #771

Merged
merged 2 commits into from
Jul 3, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.openmrs.mobile.activities.formlist;

import android.content.Intent;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
Expand All @@ -28,6 +29,8 @@
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

import com.google.android.material.snackbar.Snackbar;

import org.json.JSONException;
import org.json.JSONObject;
import org.openmrs.mobile.R;
Expand All @@ -52,6 +55,8 @@
public class FormListFragment extends ACBaseFragment<FormListContract.Presenter> implements FormListContract.View {
private ListView formList;
private static Boolean formCreateFlag;
private Snackbar snackbar;
private View root;

public static FormListFragment newInstance() {

Expand All @@ -61,7 +66,7 @@ public static FormListFragment newInstance() {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_form_list, container, false);
root = inflater.inflate(R.layout.fragment_form_list, container, false);

formList = root.findViewById(R.id.formlist);
formList.setOnItemClickListener((parent, view, position, id) -> mPresenter.listItemClicked(position, ((TextView) view).getText().toString()));
Expand All @@ -71,6 +76,22 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c

@Override
public void showFormList(String[] forms) {
if(forms.length == 0) {
snackbar = Snackbar.make(root, ApplicationConstants.EMPTY_STRING, Snackbar.LENGTH_INDEFINITE);
View customSnackBarView = getLayoutInflater().inflate(R.layout.snackbar, null);
Snackbar.SnackbarLayout snackBarLayout = (Snackbar.SnackbarLayout) snackbar.getView();
snackBarLayout.setPadding(0, 0, 0, 0);

TextView noticeField = customSnackBarView.findViewById(R.id.snackbar_text);
noticeField.setText(R.string.snackbar_no_forms_found);
TextView dismissButton = customSnackBarView.findViewById(R.id.snackbar_action_button);
Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), ApplicationConstants.TypeFacePathConstants.ROBOTO_MEDIUM);
dismissButton.setTypeface(typeface);
dismissButton.setOnClickListener(v -> snackbar.dismiss());

snackBarLayout.addView(customSnackBarView, 0);
snackbar.show();
}
formList.setAdapter(new ArrayAdapter<>(getContext(),
android.R.layout.simple_list_item_1,
android.R.id.text1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class IntroActivity : AppIntro2() {
title = getString(R.string.intro_register),
description = getString(R.string.intro_register_desc),
imageDrawable = R.drawable.ico_registry,
backgroundColor = Color.parseColor("F8793B")
backgroundColor = Color.parseColor("#F8793B")
))
addSlide(AppIntroFragment.newInstance(
title = getString(R.string.intro_find),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SplashActivity : ACBaseActivity() {
binding = ActivitySplashBinding.inflate(layoutInflater)
setContentView(binding.root)

val typeface = Typeface.createFromAsset(assets, "fonts/Roboto/Montserrat.ttf")
val typeface = Typeface.createFromAsset(assets, ApplicationConstants.TypeFacePathConstants.MONTSERRAT)
with(binding) {
organizationName.typeface = typeface
organizationName.setText(R.string.organization_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
Expand All @@ -26,6 +27,8 @@

import androidx.annotation.NonNull;

import com.google.android.material.snackbar.Snackbar;

import org.openmrs.mobile.R;
import org.openmrs.mobile.activities.ACBaseFragment;
import org.openmrs.mobile.activities.formlist.FormListActivity;
Expand All @@ -42,11 +45,13 @@
public class VisitDashboardFragment extends ACBaseFragment<VisitDashboardContract.Presenter> implements VisitDashboardContract.View {
private ExpandableListView mExpandableListView;
private TextView mEmptyListView;
private View root;
private Snackbar snackbar;

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_visit_dashboard, container, false);
root = inflater.inflate(R.layout.fragment_visit_dashboard, container, false);

mEmptyListView = root.findViewById(R.id.visitDashboardEmpty);
mExpandableListView = root.findViewById(R.id.visitDashboardExpList);
Expand Down Expand Up @@ -93,12 +98,34 @@ public void updateList(List<Encounter> visitEncounters) {
displayableEncounters.add(encounter);
}
}
setupSnackBar();
if (displayableEncounters.size() == 0) {
snackbar.show();
} else {
snackbar.dismiss();
}

VisitExpandableListAdapter expandableListAdapter = new VisitExpandableListAdapter(this.getActivity(), displayableEncounters);
mExpandableListView.setAdapter(expandableListAdapter);
mExpandableListView.setGroupIndicator(null);
}

private void setupSnackBar() {
snackbar = Snackbar.make(root, ApplicationConstants.EMPTY_STRING, Snackbar.LENGTH_INDEFINITE);
View customSnackBarView = getLayoutInflater().inflate(R.layout.snackbar, null);
Snackbar.SnackbarLayout snackBarLayout = (Snackbar.SnackbarLayout) snackbar.getView();
snackBarLayout.setPadding(0, 0, 0, 0);

TextView noticeField = customSnackBarView.findViewById(R.id.snackbar_text);
noticeField.setText(R.string.snackbar_empty_visit_list);
TextView dismissButton = customSnackBarView.findViewById(R.id.snackbar_action_button);
dismissButton.setText(R.string.snackbar_select);
Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), ApplicationConstants.TypeFacePathConstants.ROBOTO_MEDIUM);
dismissButton.setTypeface(typeface);
dismissButton.setOnClickListener(v -> mPresenter.fillForm());
snackBarLayout.addView(customSnackBarView, 0);
}

@Override
public void setEmptyListVisibility(boolean visibility) {
if (visibility) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,13 @@ object ApplicationConstants {
const val SHOW_FORM_ENTRY = 4
const val SHOW_MANAGE_PROVIDERS = 5
}

object TypeFacePathConstants {
const val MONTSERRAT = "fonts/Roboto/Montserrat.ttf"
const val ROBOTO_LIGHT = "fonts/Roboto/Roboto-Light.ttf"
const val ROBOTO_LIGHT_ITALIC = "fonts/Roboto/Roboto-LightItalic.ttf"
const val ROBOTO_MEDIUM = "fonts/Roboto/Roboto-Medium.ttf"
const val ROBOTO_MEDIUM_ITALIC = "fonts/Roboto/Roboto-MediumItalic.ttf"
const val ROBOTO_REGULAR = "fonts/Roboto/Roboto-Regular.ttf"
}
}
3 changes: 2 additions & 1 deletion openmrs-client/src/main/res/layout/snackbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toLeftOf="@id/snackbar_action_button"/>

<TextView
android:id="@+id/snackbar_action_button"
Expand Down
7 changes: 5 additions & 2 deletions openmrs-client/src/main/res/values-hi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,11 @@
<string name="form_data_sync_is_off_message">सिंक बंद है। फ़ॉर्म डेटा सहेजने के लिए सिंक चालू करें।</string>
<string name="form_data_saved_successfully">%1$s डेटा सफलतापूर्वक सहेजा गया</string>
<string name="unidentified_patient_name">अज्ञात रोगी</string>
<string name="snackbar_server_error">The entered server is currently down, please select a different one.</string>
<string name="snackbar_choose">Choose</string>
<string name="snackbar_server_error">दर्ज किया गया सर्वर वर्तमान में नीचे है, कृपया एक अलग चुनें।</string>
<string name="snackbar_empty_visit_list">मेनू से फॉर्म एंट्री का चयन करें</string>
<string name="snackbar_no_forms_found">कोई फॉर्म नहीं मिला, एप्लिकेशन को पुनरारंभ करें।</string>
<string name="snackbar_choose">चुनें</string>
<string name="snackbar_select">चुनें</string>
<string name="offline_provider_fetch">ऑफ़लाइन प्रदाता डेटाबेस के साथ सिंक नहीं कर सका, डिवाइस ऑफ़लाइन है</string>
<string name="offline_provider_add">जब डिवाइस नेटवर्क से कनेक्ट हो जाता है तो प्रदाता सर्वर से सिंक हो जाएगा</string>
<string name="offline_provider_edit">"जब डिवाइस नेटवर्क से कनेक्ट हो जाता है तो अपडेटेड प्रदाता सर्वर से सिंक हो जाएगा "</string>
Expand Down
3 changes: 3 additions & 0 deletions openmrs-client/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,10 @@

<string name="unidentified_patient_name" translatable="false">UNKNOWN</string>
<string name="snackbar_server_error">The entered server is currently down, please select a different one.</string>
<string name="snackbar_empty_visit_list">Select Form Entry from the menu to begin analyzing this patient</string>
<string name="snackbar_no_forms_found">No Forms Found, try restarting the app.</string>
<string name="snackbar_choose">Choose</string>
<string name="snackbar_select">Select</string>
<string name="url_server_list" translatable="false">https://wiki.openmrs.org/display/ISM/OpenMRS+environments</string>
<string name="copied_text" translatable="false">Copied Text</string>

Expand Down