From 235f4d614a3bb64968923c86792c23ce8a9a8f5f Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 19 Jul 2017 08:22:45 +0200 Subject: [PATCH 1/2] Allow overwriting of IOS theming values Signed-off-by: Roeland Jago Douma --- apps/theming/lib/ThemingDefaults.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 2b3be1e641..7f30a48ff8 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -51,6 +51,10 @@ class ThemingDefaults extends \OC_Defaults { private $color; /** @var Util */ private $util; + /** @var string */ + private $iTunesAppId; + /** @var string */ + private $iOSClientUrl; /** * ThemingDefaults constructor. @@ -82,6 +86,8 @@ class ThemingDefaults extends \OC_Defaults { $this->url = parent::getBaseUrl(); $this->slogan = parent::getSlogan(); $this->color = parent::getColorPrimary(); + $this->iTunesAppId = parent::getiTunesAppId(); + $this->iOSClientUrl = parent::getiOSClientUrl(); } public function getName() { @@ -180,6 +186,20 @@ class ThemingDefaults extends \OC_Defaults { return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground') . '?v=' . $cacheBusterCounter; } + /** + * @return string + */ + public function getiTunesAppId() { + return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId); + } + + /** + * @return string + */ + public function getiOSClientUrl() { + return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl); + } + /** * @return array scss variables to overwrite @@ -290,5 +310,4 @@ class ThemingDefaults extends \OC_Defaults { return $returnValue; } - } From ff9c5072f057352e988429bbafc1b8fa75b4b6d0 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 19 Jul 2017 10:20:47 +0200 Subject: [PATCH 2/2] Add Android and iOS URLs to theming app Signed-off-by: Morris Jobke --- apps/theming/lib/ThemingDefaults.php | 10 ++++ apps/theming/tests/ThemingDefaultsTest.php | 61 ++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 7f30a48ff8..dff24ee796 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -55,6 +55,8 @@ class ThemingDefaults extends \OC_Defaults { private $iTunesAppId; /** @var string */ private $iOSClientUrl; + /** @var string */ + private $AndroidClientUrl; /** * ThemingDefaults constructor. @@ -88,6 +90,7 @@ class ThemingDefaults extends \OC_Defaults { $this->color = parent::getColorPrimary(); $this->iTunesAppId = parent::getiTunesAppId(); $this->iOSClientUrl = parent::getiOSClientUrl(); + $this->AndroidClientUrl = parent::getAndroidClientUrl(); } public function getName() { @@ -200,6 +203,13 @@ class ThemingDefaults extends \OC_Defaults { return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl); } + /** + * @return string + */ + public function getAndroidClientUrl() { + return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl); + } + /** * @return array scss variables to overwrite diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index 8646eaf865..057229483e 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -543,4 +543,65 @@ class ThemingDefaultsTest extends TestCase { ]; $this->assertEquals($expected, $this->template->getScssVariables()); } + + public function testGetDefaultAndroidURL() { + $this->config + ->expects($this->once()) + ->method('getAppValue') + ->with('theming', 'AndroidClientUrl', 'https://play.google.com/store/apps/details?id=com.nextcloud.client') + ->willReturn('https://play.google.com/store/apps/details?id=com.nextcloud.client'); + + $this->assertEquals('https://play.google.com/store/apps/details?id=com.nextcloud.client', $this->template->getAndroidClientUrl()); + } + + public function testGetCustomAndroidURL() { + $this->config + ->expects($this->once()) + ->method('getAppValue') + ->with('theming', 'AndroidClientUrl', 'https://play.google.com/store/apps/details?id=com.nextcloud.client') + ->willReturn('https://play.google.com/store/apps/details?id=com.mycloud.client'); + + $this->assertEquals('https://play.google.com/store/apps/details?id=com.mycloud.client', $this->template->getAndroidClientUrl()); + } + + public function testGetDefaultiOSURL() { + $this->config + ->expects($this->once()) + ->method('getAppValue') + ->with('theming', 'iOSClientUrl', 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8') + ->willReturn('https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'); + + $this->assertEquals('https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8', $this->template->getiOSClientUrl()); + } + + public function testGetCustomiOSURL() { + $this->config + ->expects($this->once()) + ->method('getAppValue') + ->with('theming', 'iOSClientUrl', 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8') + ->willReturn('https://itunes.apple.com/us/app/nextcloud/id1234567890?mt=8'); + + $this->assertEquals('https://itunes.apple.com/us/app/nextcloud/id1234567890?mt=8', $this->template->getiOSClientUrl()); + } + + public function testGetDefaultiTunesAppId() { + $this->config + ->expects($this->once()) + ->method('getAppValue') + ->with('theming', 'iTunesAppId', '1125420102') + ->willReturn('1125420102'); + + $this->assertEquals('1125420102', $this->template->getiTunesAppId()); + } + + public function testGetCustomiTunesAppId() { + $this->config + ->expects($this->once()) + ->method('getAppValue') + ->with('theming', 'iTunesAppId', '1125420102') + ->willReturn('1234567890'); + + $this->assertEquals('1234567890', $this->template->getiTunesAppId()); + } + }