Skip to content

Commit

Permalink
Offline support issue resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
mithunvaghela committed Dec 1, 2023
1 parent af35bb0 commit 7514343
Show file tree
Hide file tree
Showing 17 changed files with 3,166 additions and 21 deletions.
2 changes: 0 additions & 2 deletions Old Issue

This file was deleted.

14 changes: 14 additions & 0 deletions Release Note
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Release 2.4-Beta 01/12/2023
===========================
- Patient list ordered with newest registered
- Made profile picture scrollable in patient personal info
- Patient registration top three tab margin improved
- ELCG offline support partially added
- Dr web app - Login page in responsive mode : Login screen set on top under scroll then eZazi screen.
- Minimum patient age limit increased by 13 year old
- ELCG login issue resolved while opening from mobile or tablet
- Fetal position, Urine Protein, Urine Acetone and Moulding value changed with standard format
- Date added in timeline screen with each encounter
- Minor text changes

Offline support
5 changes: 1 addition & 4 deletions Sprint Changes
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ Patient list ranking should be ordered new to old in find patient listing. - Don
Patient registration - make the scroll same as IDA app. Profile image should scroll. - Done
Patient registration - Top three tabs size & margin should same as IDA app. - Done
View e-partogram - In offline mode its giving 404 error also asking for login credentials some times. ePartogram view should work in offile mode as well.
- To show the WHO LCG View, we are directly loading the web page url through webview in app only,
so we have cached whole html page, when there is no internet, it will load page from cache.
It will represent the html format instead on 404, but very first time it require to load successfully
when internet is available. This
- Partially achieved
Dr web app PWA - PWA splash screen should be same as mobile app splash screen with same logo & colors.
Dr web app - Login page in responsive mode : Login screen should be on top under scroll then eZazi screen. (Same as IDA) - Done
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.text.Html;
import android.util.Log;
import android.util.Xml;
Expand All @@ -30,11 +31,16 @@
import org.intelehealth.ezazi.ui.elcg.HtmlJSInterface;
import org.intelehealth.ezazi.ui.shared.BaseActionBarActivity;
import org.intelehealth.ezazi.ui.dialog.ConfirmationDialogFragment;
import org.intelehealth.ezazi.ui.webviewreader.Lt;
import org.intelehealth.ezazi.ui.webviewreader.WebArchiveReader;
import org.intelehealth.ezazi.utilities.FileUtils;
import org.intelehealth.ezazi.utilities.NetworkConnection;
import org.intelehealth.ezazi.utilities.SessionManager;
import org.intelehealth.ezazi.widget.materialprogressbar.CustomProgressDialog;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import io.socket.utf8.UTF8;

Expand All @@ -52,13 +58,15 @@ public class EpartogramViewActivity extends BaseActionBarActivity {
private String webArchiveFileDir;
private SessionManager sessionManager;

private boolean isLoaded = false;

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_epartogram_ezazi);
super.onCreate(savedInstanceState);
sessionManager = new SessionManager(this);
webArchiveFileDir = getBaseContext().getCacheDir().getAbsolutePath() + File.separator;
webArchiveFileDir = FileUtils.getProjectCatchDir(this);
Timber.tag(TAG).d("webArchive =>%s", webArchiveFileDir);
Intent intent = this.getIntent();
if (intent != null) {
Expand All @@ -70,18 +78,18 @@ protected void onCreate(Bundle savedInstanceState) {
webView = findViewById(R.id.webview_epartogram);
mySwipeRefreshLayout = (SwipeRefreshLayout) this.findViewById(R.id.swipeContainer);

webView.setWebViewClient(webViewClient);

webView.setSaveEnabled(true);
HtmlJSInterface htmlJSInterface = new HtmlJSInterface();
webView.addJavascriptInterface(htmlJSInterface, HtmlJSInterface.EXECUTOR_PAGE_SAVER);
// HtmlJSInterface htmlJSInterface = new HtmlJSInterface();
// webView.addJavascriptInterface(htmlJSInterface, HtmlJSInterface.EXECUTOR_PAGE_SAVER);

webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ONLY);
webView.getSettings().setUserAgentString("Android");

webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW);
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setDefaultTextEncodingName("UTF-8");

Expand All @@ -93,15 +101,15 @@ protected void onCreate(Bundle savedInstanceState) {
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(false);
webView.setVisibility(View.VISIBLE);

webView.setWebViewClient(webViewClient);

if (NetworkConnection.isOnline(this)) webView.loadUrl(URL + visitUuid);
else if (!sessionManager.getLCGContentFile(visitUuid).isEmpty()) {
String webArchiveFile = webArchiveFileDir + sessionManager.getLCGContentFile(visitUuid);
Timber.tag(TAG).d("Offline => %s", webArchiveFile);
// webView.loadUrl(webArchiveFile);
webView.loadUrl("file://" + webArchiveFile);
// webView.loadData(htmlJSInterface.getHtml(), "text/html", null);
webView.loadDataWithBaseURL(null, htmlJSInterface.getHtml(), "text/html", "UTF-8", null);
// webView.loadDataWithBaseURL(null, htmlJSInterface.getHtml(), "text/html", "UTF-8", null);
} else {
webView.setVisibility(View.GONE);
Toast.makeText(this, getString(R.string.please_connect_to_internet), Toast.LENGTH_LONG).show();
Expand All @@ -112,15 +120,28 @@ else if (!sessionManager.getLCGContentFile(visitUuid).isEmpty()) {
}

private final WebViewClient webViewClient = new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
String webArchiveFile = webArchiveFileDir + sessionManager.getLCGContentFile(visitUuid);
Timber.tag(TAG).d("Offline => %s", webArchiveFile);
webView.loadUrl("file://" + webArchiveFile);
return true;
}

@Override
public void onPageFinished(WebView view, String url) {
mySwipeRefreshLayout.setRefreshing(false);
if (NetworkConnection.isOnline(EpartogramViewActivity.this)) {
String fileName = visitUuid + ".mht";
Timber.tag(TAG).d("fileName => %s", fileName);
sessionManager.setLCGContentFile(fileName, visitUuid);
view.saveWebArchive(webArchiveFileDir + fileName);
view.loadUrl(HtmlJSInterface.jsFunction());
String filePath = webArchiveFileDir + fileName;
File archive = new File(filePath);
if (archive.exists()) {
if (archive.delete()) view.saveWebArchive(filePath);
} else view.saveWebArchive(filePath);

// view.loadUrl(HtmlJSInterface.jsFunction());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ public static TreeMap<String, List<ParamInfo>> getSectionParamInfoMasterMap(int
paramInfo.setParamSectionName(SECTION_LIST[1]);
paramInfo.setParamName(Params.AMNIOTIC_FLUID.value);
paramInfo.setParamDateType(DROPDOWN_SINGLE_SELECT_TYPE);
paramInfo.setOptions(new String[]{"Intact", "Clear", "Meconium-Stained Fluid (Non-significant)", "Meconium-Stained Fluid (Medium)",
"Meconium-Stained Fluid (Thick)", "Blood Stained"});
paramInfo.setOptions(new String[]{"I (Intact)", "C (Clear fluid)", "M+ (Meconium stained fluid-Nonsignificant)",
"M++ (Meconium stained fluid-Medium)", "M+++ (Meconium stained fluid-Thick)", "B (Blood stained)"});
paramInfo.setValues(new String[]{"I", "C", "M+", "M++", "M+++", "B"});
paramInfo.setConceptUUID("9d3160a6-538f-11e6-9cfe-86f436325720");
stringList.add(paramInfo);
Expand Down
Loading

0 comments on commit 7514343

Please sign in to comment.