diff --git a/admin/tool/mobile/lang/en/tool_mobile.php b/admin/tool/mobile/lang/en/tool_mobile.php
index 842f45bfc2b..1818a2f405e 100644
--- a/admin/tool/mobile/lang/en/tool_mobile.php
+++ b/admin/tool/mobile/lang/en/tool_mobile.php
@@ -22,6 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+$string['androidappid'] = 'Android app\'s unique identifier';
+$string['androidappid_desc'] = 'This setting may be left as default unless you have a custom Android app.';
$string['autologinkeygenerationlockout'] = 'Auto-login key generation is blocked because of too many requests within an hour.';
$string['autologinnotallowedtoadmins'] = 'Auto-login is not allowed for site admins.';
$string['clickheretolaunchtheapp'] = 'Click here if the app does not open automatically.';
@@ -44,15 +46,15 @@ Mis calificaciones | https://someurl.xyz/local/mygrades/index.php | embedded | e
Use inappbrowser when you want to open the link in a browser without leaving the app, use browser for opening the link in the device default browser and embedded if you want to display the link embedded in a new page in the app.';
$string['disabledfeatures'] = 'Disabled features';
$string['disabledfeatures_desc'] = 'Select here the features you want to disable in the Mobile app for your site. Please note that some features listed here could be already disabled via other site settings. You will have to log out and log in again in the app to see the changes.';
-$string['enablesmartappbanners'] = 'Enable Smart App Banners';
-$string['enablesmartappbanners_desc'] = 'This will display a banner promoting the Moodle Mobile app when visiting the site in Mobile Safari.';
+$string['enablesmartappbanners'] = 'Enable App Banners';
+$string['enablesmartappbanners_desc'] = 'This will display a banner promoting the Moodle Mobile app when visiting the site in a Mobile browser.';
$string['forcedurlscheme'] = 'If you want to allow only your custom branded app to be opened via a browser window, then specify its URL scheme here; otherwise leave the field empty.';
$string['forcedurlscheme_key'] = 'URL scheme';
$string['forcelogout'] = 'Force log out';
$string['forcelogout_desc'] = 'If enabled, the app option \'Change site\' is replaced by \'Log out\'. This results in the user being completely logged out. They must then re-enter their password the next time they wish to access the site.';
$string['httpsrequired'] = 'HTTPS required';
$string['invalidprivatetoken'] = 'Invalid private token. Token should not be empty or passed via GET parameter.';
-$string['iosappid'] = 'App\'s unique identifier';
+$string['iosappid'] = 'iOS app\'s unique identifier';
$string['iosappid_desc'] = 'This setting may be left as default unless you have a custom iOS app.';
$string['loginintheapp'] = 'Via the app';
$string['logininthebrowser'] = 'Via a browser window (for SSO plugins)';
@@ -65,7 +67,7 @@ $string['mobilecssurl'] = 'CSS';
$string['mobilefeatures'] = 'Mobile features';
$string['mobilesettings'] = 'Mobile settings';
$string['pluginname'] = 'Moodle Mobile tools';
-$string['smartappbanners'] = 'Smart App Banners (iOS only)';
+$string['smartappbanners'] = 'App Banners';
$string['pluginnotenabledorconfigured'] = 'Plugin not enabled or configured.';
$string['remoteaddons'] = 'Remote add-ons';
$string['typeoflogin'] = 'Type of login';
diff --git a/admin/tool/mobile/lib.php b/admin/tool/mobile/lib.php
index 9717c5372d9..de43b8190da 100644
--- a/admin/tool/mobile/lib.php
+++ b/admin/tool/mobile/lib.php
@@ -36,9 +36,16 @@ function tool_mobile_before_standard_html_head() {
// Smart App Banners meta tag is only displayed if mobile services are enabled and configured.
if (!empty($CFG->enablemobilewebservice)) {
$mobilesettings = get_config('tool_mobile');
- if (!empty($mobilesettings->enablesmartappbanners) and !empty($mobilesettings->iosappid)) {
- $output .= '';
+ if (!empty($mobilesettings->enablesmartappbanners)) {
+ if (!empty($mobilesettings->iosappid)) {
+ $output .= '';
+ }
+
+ if (!empty($mobilesettings->androidappid)) {
+ $mobilemanifesturl = "$CFG->wwwroot/$CFG->admin/tool/mobile/mobile.webmanifest.php";
+ $output .= '';
+ }
}
}
return $output;
diff --git a/admin/tool/mobile/mobile.webmanifest.php b/admin/tool/mobile/mobile.webmanifest.php
new file mode 100644
index 00000000000..ac9bb5fa7e8
--- /dev/null
+++ b/admin/tool/mobile/mobile.webmanifest.php
@@ -0,0 +1,59 @@
+.
+
+/**
+ * Web manifest for including a native app banner.
+ *
+ * The banner is only displayed if the user has visited the site twice over two separate days during the course of two weeks.
+ * More information here: https://developer.android.com/distribute/users/banners.html
+ *
+ * @package tool_mobile
+ * @copyright 2017 Juan Leyva
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+define('NO_DEBUG_DISPLAY', true);
+define('NO_MOODLE_COOKIES', true);
+
+require_once(__DIR__ . '/../../../config.php');
+use tool_mobile\api;
+
+header('Content-Type: application/json; charset: utf-8');
+
+$mobilesettings = get_config('tool_mobile');
+// Display manifest contents only if all the required conditions are met.
+if (!empty($CFG->enablemobilewebservice) && !empty($mobilesettings->enablesmartappbanners) &&
+ !empty($mobilesettings->androidappid)) {
+
+ $manifest = new StdClass;
+ $manifest->short_name = format_string($SITE->shortname);
+ $manifest->prefer_related_applications = true;
+ $manifest->icons = [(object)
+ [
+ 'sizes' => '144x144',
+ 'type' => 'image/png',
+ 'src' => "$CFG->wwwroot/$CFG->admin/tool/mobile/pix/icon_144.png"
+ ]
+ ];
+ $manifest->related_applications = [(object)
+ [
+ 'platform' => 'play',
+ 'id' => $mobilesettings->androidappid,
+ ]
+ ];
+ echo json_encode($manifest);
+}
+die;
diff --git a/admin/tool/mobile/pix/icon_144.png b/admin/tool/mobile/pix/icon_144.png
new file mode 100644
index 00000000000..70c15c65118
Binary files /dev/null and b/admin/tool/mobile/pix/icon_144.png differ
diff --git a/admin/tool/mobile/settings.php b/admin/tool/mobile/settings.php
index 2700816bb52..4f8630c95b6 100644
--- a/admin/tool/mobile/settings.php
+++ b/admin/tool/mobile/settings.php
@@ -80,6 +80,9 @@ if ($hassiteconfig) {
$temp->add(new admin_setting_configtext('tool_mobile/iosappid', new lang_string('iosappid', 'tool_mobile'),
new lang_string('iosappid_desc', 'tool_mobile'), '633359593', PARAM_ALPHANUM));
+ $temp->add(new admin_setting_configtext('tool_mobile/androidappid', new lang_string('androidappid', 'tool_mobile'),
+ new lang_string('androidappid_desc', 'tool_mobile'), 'com.moodle.moodlemobile', PARAM_NOTAGS));
+
$ADMIN->add('mobileapp', $temp);
// Features related settings.
diff --git a/admin/tool/mobile/version.php b/admin/tool/mobile/version.php
index c83e26ade4f..4632c5d72a9 100644
--- a/admin/tool/mobile/version.php
+++ b/admin/tool/mobile/version.php
@@ -23,7 +23,7 @@
*/
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016120504; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->version = 2016120505; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2016112900; // Requires this Moodle version.
$plugin->component = 'tool_mobile'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = array(