From dee254718793f4e137aa42b8ed6fb7c6149a3e70 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Mon, 5 Oct 2020 15:42:25 +1100 Subject: [PATCH 1/3] feat(android): Android install page --- keyboards/install.php | 112 +++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/keyboards/install.php b/keyboards/install.php index c670d755..1c1ff936 100644 --- a/keyboards/install.php +++ b/keyboards/install.php @@ -53,36 +53,14 @@ public static function render_keyboard_details($id, $tier, $bcp47) { self::LoadData(); self::WriteTitle(); - self::WriteDownloadBoxes(); - Foot::render(); - } - - protected static function download_box($keymanProductName, $keymanUrl, $title, $description, $class, $linktitle, $platform, $mode='standalone') { - - if(isset(self::$keyboard->platformSupport->$platform) && self::$keyboard->platformSupport->$platform != 'none') { - $id = self::$id; - $e_id = urlencode($id); + echo self::WriteWindowsBoxes(); + echo self::WritemacOSBoxes(); + echo self::WriteLinuxBoxes(); + echo self::WriteAndroidBoxes(); + echo self::WriteiOSBoxes(); - // TODO: this won't work now, needs rewrite for other platforms - // TODO: copying the WriteWindowsBoxes function - $url = "/keyboard/download?id=$e_id&platform=$platform&mode=$mode"; - if(!empty(self::$bcp47)) $url .= "&bcp47=".rawurlencode(self::$bcp47); - $url = htmlspecialchars($url); - return << - -
    -
  1. Install $keymanProductName
  2. -
  3. Install $title
  4. -
- - -END; - } else { - // TODO: this message not yet clear - return "
Not available for $platform
"; - } + Foot::render(); } protected static function WriteWindowsBoxes() { @@ -136,7 +114,7 @@ protected static function WriteWindowsBoxes() { return $result; } - protected static function WriteMacOSBoxes() { + protected static function WritemacOSBoxes() { $keyboard = self::$keyboard; $tier = self::$tier; $version = self::$versions->mac->$tier; @@ -252,14 +230,56 @@ protected static function WriteLinuxBoxes() { } protected static function WriteAndroidBoxes() { - return self::download_box( - 'Keyman for Android', - PlayStore::url, - htmlentities(self::$keyboard->name) . ' for Android', - 'Installs only ' . htmlentities(self::$keyboard->name) . '. Keyman for Android must be installed first.', - 'download-android', - 'Install on Android', - 'android'); + $keyboard = self::$keyboard; + $tier = self::$tier; + $version = self::$versions->android->$tier; + + $e = [ + 'name' => $keyboard->name, + 'host' => KeymanHosts::Instance()->downloads_keyman_com, + 'tier' => $tier, + 'version' => $version, + 'id' => $keyboard->id, + 'bcp47' => empty(self::$bcp47) ? '' : self::$bcp47, + ]; + + $u = array_map('rawurlencode', $e); + $hu = array_map('htmlentities', $u); + $h = array_map('htmlentities', $e); + + // Note, we don't need to capture an event for the keyboard download here, because we'll + // capture it in the /go/package/download step + + $downloadLink = KeymanHosts::Instance()->keyman_com . "/go/package/download/{$hu['id']}" . + "?platform=android&version={$hu['version']}&tier={$hu['tier']}" . + (empty($hu['bcp47']) ? "" : "&bcp47={$hu['bcp47']}"); + + $helpLink = KeymanHosts::Instance()->help_keyman_com . "/products/android/current-version/installing-keyboards"; + + $keyboardHomeUrl = "/keyboards/{$hu['id']}" . + (empty($hu['bcp47']) ? "" : "?bcp47=" . $hu['bcp47']); + + $downloadKeymanUrl = PlayStore::url; + + $result = << +
+

If you have not yet installed Keyman for Android, please install it first before installing the keyboard.

+
    +
  1. Install Keyman for Android
  2. +
  3. + Install keyboard +
    Downloads {$h['name']} for Android.
    +
  4. +
+ +
+ +END; + return $result; } protected static function WriteiOSBoxes() { @@ -382,22 +402,4 @@ protected static function WriteTitle() {

"self::WriteWindowsBoxes", - "mac" => "self::WritemacOSBoxes", - "Linux" => "self::WriteLinuxBoxes", - "iOS" => "self::WriteiOSBoxes", - "Android" => "self::WriteAndroidBoxes" - ); - - foreach($deviceboxfuncs as $device => $func) { - echo call_user_func($func); - } - - //?echo ""; - } } From d5116ee08c5f994ae16dda8da24c282da65a2a7d Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 7 Oct 2020 10:36:09 +1100 Subject: [PATCH 2/3] fix: download links used wrong version --- keyboards/install.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/keyboards/install.php b/keyboards/install.php index 1c1ff936..fa9ca20b 100644 --- a/keyboards/install.php +++ b/keyboards/install.php @@ -123,7 +123,7 @@ protected static function WritemacOSBoxes() { 'name' => $keyboard->name, 'host' => KeymanHosts::Instance()->downloads_keyman_com, 'tier' => $tier, - 'version' => $version, + 'keyboardversion' => $keyboard->version, 'id' => $keyboard->id, 'bcp47' => empty(self::$bcp47) ? '' : self::$bcp47, ]; @@ -136,8 +136,8 @@ protected static function WritemacOSBoxes() { // capture it in the /go/package/download step $downloadLink = KeymanHosts::Instance()->keyman_com . "/go/package/download/{$hu['id']}" . - "?platform=macos&version={$hu['version']}&tier={$hu['tier']}" . - (empty($hu['bcp47']) ? "" : "&bcp47={$hu['bcp47']}"); + "?platform=macos&version={$hu['keyboardversion']}&tier={$hu['tier']}" . + (empty($hu['bcp47']) ? "" : "&bcp47={$hu['bcp47']}"); $helpLink = KeymanHosts::Instance()->help_keyman_com . "/products/mac/current-version/start/install-keyboard"; @@ -176,7 +176,7 @@ protected static function WriteLinuxBoxes() { 'name' => $keyboard->name, 'host' => KeymanHosts::Instance()->downloads_keyman_com, 'tier' => $tier, - 'version' => $version, + 'keyboardversion' => $keyboard->version, 'id' => $keyboard->id, 'bcp47' => empty(self::$bcp47) ? '' : self::$bcp47, ]; @@ -189,8 +189,8 @@ protected static function WriteLinuxBoxes() { // capture it when the bootstrap downloads the file. $downloadLink = KeymanHosts::Instance()->keyman_com . "/go/package/download/{$hu['id']}" . - "?platform=linux&version={$hu['version']}&tier={$hu['tier']}" . - (empty($hu['bcp47']) ? "" : "&bcp47={$hu['bcp47']}"); + "?platform=linux&version={$hu['keyboardversion']}&tier={$hu['tier']}" . + (empty($hu['bcp47']) ? "" : "&bcp47={$hu['bcp47']}"); $helpLink = KeymanHosts::Instance()->help_keyman_com . "/products/linux/current-version/guide/installing-keyboard"; @@ -238,7 +238,7 @@ protected static function WriteAndroidBoxes() { 'name' => $keyboard->name, 'host' => KeymanHosts::Instance()->downloads_keyman_com, 'tier' => $tier, - 'version' => $version, + 'version' => $keyboard->version, 'id' => $keyboard->id, 'bcp47' => empty(self::$bcp47) ? '' : self::$bcp47, ]; @@ -251,8 +251,8 @@ protected static function WriteAndroidBoxes() { // capture it in the /go/package/download step $downloadLink = KeymanHosts::Instance()->keyman_com . "/go/package/download/{$hu['id']}" . - "?platform=android&version={$hu['version']}&tier={$hu['tier']}" . - (empty($hu['bcp47']) ? "" : "&bcp47={$hu['bcp47']}"); + "?platform=android&version={$hu['version']}&tier={$hu['tier']}" . + (empty($hu['bcp47']) ? "" : "&bcp47={$hu['bcp47']}"); $helpLink = KeymanHosts::Instance()->help_keyman_com . "/products/android/current-version/installing-keyboards"; From a26c4e917db376977e6ec8e175e42671418a017d Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 7 Oct 2020 10:38:41 +1100 Subject: [PATCH 3/3] chore: remove unused variables --- keyboards/install.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/keyboards/install.php b/keyboards/install.php index fa9ca20b..a99f075f 100644 --- a/keyboards/install.php +++ b/keyboards/install.php @@ -65,7 +65,6 @@ public static function render_keyboard_details($id, $tier, $bcp47) { protected static function WriteWindowsBoxes() { $keyboard = self::$keyboard; - $bcp47 = rawurlencode(empty(self::$bcp47) ? '' : self::BOOTSTRAP_SEPARATOR.self::$bcp47); $tier = self::$tier; $version = self::$versions->windows->$tier; @@ -117,7 +116,6 @@ protected static function WriteWindowsBoxes() { protected static function WritemacOSBoxes() { $keyboard = self::$keyboard; $tier = self::$tier; - $version = self::$versions->mac->$tier; $e = [ 'name' => $keyboard->name, @@ -170,7 +168,6 @@ protected static function WritemacOSBoxes() { protected static function WriteLinuxBoxes() { $keyboard = self::$keyboard; $tier = self::$tier; - $version = self::$versions->linux->$tier; $e = [ 'name' => $keyboard->name, @@ -232,7 +229,6 @@ protected static function WriteLinuxBoxes() { protected static function WriteAndroidBoxes() { $keyboard = self::$keyboard; $tier = self::$tier; - $version = self::$versions->android->$tier; $e = [ 'name' => $keyboard->name,