Using a html file project to access offline content from the app

Using a html file project to access offline content from the app

by Sourabh Maheshwari -
Number of replies: 5

Hi,

In order to make our content available offline we have designed a html based project which can be opened in the mobile browser and uses local storage to access the content. 

We thought of using MM2 app to do both the online and offline access and so we allowed the index html file to get Force Download from the courses which will get saved in com.moodle.moodlemobile folder and then we can ask our users to paste the offline content asset folder at the same location as that of the index file and with proper links in the index file it can be accessed from MM2.

Everything worked well except for the indexpage not opening some of the files which are our custom extensions (encrypted files to be opened in another app). These files are linked with the intent property of android chrome and are working fine if you open the index file normally and not from MM2. It also did not allow to install this external app and other apps from the index file which could be helpful for users. And the html pages with pictures did not open as responsive pages and got distorted. 

Please see the index file to get more clarity.

Please suggest ways to create a separate folder in internal or external storage directories to save the files rather than the file being getting saved in Android->data->site..folder. Like Shareit or other apps creating a separate folder in directory. Also kindly help to resolve these issues of opening intent linked files and relative file path in a html file.

You can also test this as it is an auto enrolment course and you can login with Google at www.saamarthyaved.com

Thanks in advance,

Sourabh

 




 



Average of ratings: -
In reply to Sourabh Maheshwari

Re: Using a html file project to access offline content from the app

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Sourabh,

I don't understand much what you're trying to achieve, so maybe some of my comments don't make any sense. Can't you include the "offline content asset folder" in the same resource as the index HTML? That way the users wouldn't have to manually paste it.

You can use an HTML mini-site, that is, create a new activity of type "File", add ALL the files in there and use the index HTML as the main file. In this case, the app downloads all the files inside the same folder, isolated from the rest of the activities, and opens the main file in an iframe.

Regarding the intent problem, I guess it's the data-hasintent and data-contentpath properties, right? I didn't know about them, we'll take a look to see if we can make them work inside the app.

Kind regards,

Dani

In reply to Dani Palou

Re: Using a html file project to access offline content from the app

by Sourabh Maheshwari -

Thanks Dani for the prompt response.

The pasting is required as the total content is around 1.5 gb and the internet is not that good everywhere here so sending a cd is the best way. Otherwise what you suggested would be best to do.

I have tried to cover the functioning in this screencast:


This is about intents: https://developer.chrome.com/multidevice/android/intents

Data has intent and content path is the JavaScript for making the page dynamic and open our video which are encrypted as .arth files in a specific video player app. Hereis the code:

function GetAssetLinksForAndroid()

{

$('a').each(function () {

                if ($(this).data('hasintent') == "1") {

                    var url1 = "intent://";

                    var absolutePath = new RegExp('[^?]+/').exec(location.href);

var assetPos = absolutePath.toString().toLowerCase().indexOf("asset");

if(assetPos != -1)

{

absolutePath = absolutePath.toString().substring(0, assetPos);

}

                    var contentPath = "asset/content/" + $(this).data('contentpath')

                    var url2 = "#Intent;action=android.intent.action.VIEW;package=com.xyx

Player;scheme=file;type=video/*;end";

                    var fullUrl = url1 + absolutePath + contentPath + url2; 

                    $(this).attr("href", fullUrl);

                }

            });

}


Thanks again

Rgds,

Sourabh


Openhtml app and android browser support intents.

In reply to Sourabh Maheshwari

Re: Using a html file project to access offline content from the app

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Sourabh,

I opened an issue to support intent links:

https://tracker.moodle.org/browse/MOBILE-1668

Thank you for suggesting this,

Dani

In reply to Dani Palou

Re: Using a html file project to access offline content from the app

by Sourabh Maheshwari -

Many thanks Dani for taking this up.

The other things which can also be looked into is opening/downloading of files like apk. I am not sure if its a issue with iframe that it did not show the apk file from a relative local storage path. I tried to install moodle app via index file but it gave some error. Please see the video for details. It was a relative path for the file so it should have worked.   

Thanks again,

Regards,

Sourabh



In reply to Dani Palou

Re: Using a html file project to access offline content from the app

by Sourabh Maheshwari -

Hi Dani,

For our offline browsing app wo work without internet we recently worked on the webview in Android Studio and we faced the similar problem with intents there but with shouldoverrideURLLoading method we have it working without the problem. Here is the code:

public boolean shouldOverrideUrlLoading(final WebView mWebView, final String url) {
if (url.startsWith("intent://")){
final Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setPackage(packageName);
// The following flags launch the app outside the current app

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.getPackageManager();
context.startActivity(intent);

return true;
}

return false;
}


Similar thing can be done in Iframe I suppose. I don't know coding as such so cannot find that out.

Thanks