Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature/add-demo-account] Add Account: Provide Demo Account Setup #826

Open
wants to merge 2 commits into
base: milestone/11.4.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 42 additions & 1 deletion ownCloud/Resources/Theming/Branding.plist
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
<dict>
<key>Profiles</key>
<array>
<dict>
<key>identifier</key>
<string>demo.ownCloud.com</string>
<key>name</key>
<string>ownCloud</string>
<key>welcome</key>
<string>Welcome to the ownCloud Demo Account</string>
<key>promptForPasswordAuth</key>
<string>Enter your username and password</string>
<key>promptForTokenAuth</key>
<string>Tap on &quot;Continue&quot; to login to the demo account.</string>
<key>promptForURL</key>
<string></string>
<key>promptForHelpURL</key>
<string>Get more information about ownCloud</string>
<key>helpURLButtonString</key>
<string>Visit ownCloud.com</string>
<key>bookmarkName</key>
<string>demo.ownCloud.com</string>
<key>url</key>
<string>https://demo.ownCloud.com</string>
<key>canConfigureURL</key>
<false/>
<key>helpURL</key>
<string>https://owncloud.com</string>
<key>allowedHosts</key>
<array>
<string>owncloud.online</string>
<string>owncloud.com</string>
<string>owncloud.team</string>
</array>
<key>allowedAuthenticationMethods</key>
<array>
<string>com.owncloud.basicauth</string>
<string>com.owncloud.oauth2</string>
</array>
</dict>
</array>
</dict>
</plist>
Binary file modified ownCloud/Resources/Theming/branding-login-background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ownCloud/Resources/Theming/branding-login-logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions ownCloud/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
/* Add / Edit Bookmark */
"Edit account" = "Edit account";
"Add account" = "Add account";
"Personal Account" = "Personal Account";
"Demo Account" = "Demo Account";
"Server URL" = "Server URL";
"https://example.com" = "https://example.com";
"Continue" = "Continue";
Expand Down
78 changes: 71 additions & 7 deletions ownCloud/Server List/ServerListTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,7 @@ class ServerListTableViewController: UITableViewController, Themeable {
self.tableView.dragDelegate = self
extendedLayoutIncludesOpaqueBars = true

if VendorServices.shared.canAddAccount {
let addServerBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.add, target: self, action: #selector(addBookmark))
addServerBarButtonItem.accessibilityLabel = "Add account".localized
addServerBarButtonItem.accessibilityIdentifier = "addAccount"
self.navigationItem.rightBarButtonItem = addServerBarButtonItem
}
setupAddBookmarkActions()

// This view is nil, when branded app version
if welcomeOverlayView != nil {
Expand Down Expand Up @@ -345,9 +340,77 @@ class ServerListTableViewController: UITableViewController, Themeable {
}
}

func setupAddBookmarkActions() {
if VendorServices.shared.canAddAccount {
var addServerBarButtonItem: UIBarButtonItem!

if #available(iOS 14.0, *), OCBookmarkManager.shared.bookmarks.count == 0 {
addServerBarButtonItem = UIBarButtonItem(systemItem: .add, primaryAction: nil, menu: createAddBookmarkMenu())
welcomeAddServerButton.menu = createAddBookmarkMenu()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hosy is menu support not available on iOS13?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for UIBarButtonItem and UIButton only for contextual menus

welcomeAddServerButton.showsMenuAsPrimaryAction = true
} else {
addServerBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addBookmark))
}

addServerBarButtonItem.accessibilityLabel = "Add account".localized
addServerBarButtonItem.accessibilityIdentifier = "addAccount"
self.navigationItem.rightBarButtonItem = addServerBarButtonItem
}
}

@available(iOS 13.0, *)
func createAddBookmarkMenu() -> UIMenu {
let personalAction = UIAction(
title: "Personal Account".localized,
image: UIImage(systemName: "person.badge.plus")
) { (_) in
self.showBookmarkUI()
}

let demoAction = UIAction(
title: "Demo Account".localized,
image: UIImage(systemName: "globe")
) { (_) in
let staticLoginViewController = StaticLoginViewController(with: StaticLoginBundle.defaultBundle, ignore: true)
let navigationController = ThemeNavigationController(rootViewController: staticLoginViewController)
self.navigationController?.present(navigationController, animated: true, completion: nil)
}

let menuActions = [personalAction, demoAction]

let addNewMenu = UIMenu(
title: "",
children: menuActions)

return addNewMenu
}

// MARK: - Actions
@IBAction func addBookmark() {
showBookmarkUI()
if OCBookmarkManager.shared.bookmarks.count == 0 {
let controller = ThemedAlertController(title: "Add account".localized, message: nil, preferredStyle: .alert)

let personalAction = UIAlertAction(title: "Personal Account".localized, style: .default, handler: { (_) in
self.showBookmarkUI()
})

controller.addAction(personalAction)

let demoAction = UIAlertAction(title: "Demo Account".localized, style: .default, handler: { (_) in
let staticLoginViewController = StaticLoginViewController(with: StaticLoginBundle.defaultBundle, ignore: true)
let navigationController = ThemeNavigationController(rootViewController: staticLoginViewController)
self.navigationController?.present(navigationController, animated: true, completion: nil)
})
controller.addAction(demoAction)

// Cancel button
let cancelAction = UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil)
controller.addAction(cancelAction)

self.present(controller, animated: true)
} else {
self.showBookmarkUI()
}
}

func showBookmarkUI(edit bookmark: OCBookmark? = nil, performContinue: Bool = false, attemptLoginOnSuccess: Bool = false, autosolveErrorOnSuccess: NSError? = nil, removeAuthDataFromCopy: Bool = true) {
Expand Down Expand Up @@ -499,6 +562,7 @@ class ServerListTableViewController: UITableViewController, Themeable {
if !self.ignoreServerListChanges {
self.tableView.reloadData()
self.updateNoServerMessageVisibility()
self.setupAddBookmarkActions()
}
}
}
Expand Down
27 changes: 16 additions & 11 deletions ownCloud/Server List/ServerListTableViewController.xib
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_0" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17126"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -22,8 +22,8 @@
<tableView opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" bouncesZoom="NO" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="vLr-E1-eTs"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<outlet property="dataSource" destination="-1" id="Tng-2m-Rnh"/>
<outlet property="delegate" destination="-1" id="9aC-8N-iBw"/>
Expand All @@ -35,22 +35,22 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PJc-v9-DYn" userLabel="Welcome Overlay">
<rect key="frame" x="39.5" y="121" width="241.5" height="326"/>
<rect key="frame" x="40" y="121" width="240" height="326"/>
<subviews>
<imageView opaque="NO" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="fP1-O2-lkg">
<rect key="frame" x="0.0" y="0.0" width="241.5" height="128"/>
<rect key="frame" x="0.0" y="0.0" width="240" height="128"/>
<constraints>
<constraint firstAttribute="height" constant="128" id="r4R-sD-MMg"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="1000" verticalCompressionResistancePriority="1000" text="Welcome" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c8n-gy-7HF">
<rect key="frame" x="0.0" y="158" width="241.5" height="41"/>
<rect key="frame" x="0.0" y="158" width="240" height="41"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="34"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="1000" verticalCompressionResistancePriority="1000" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Jaa-D8-ghC" customClass="ThemeButton" customModule="ownCloudAppShared">
<rect key="frame" x="0.0" y="283" width="241.5" height="43"/>
<rect key="frame" x="0.0" y="283" width="240" height="43"/>
<color key="backgroundColor" red="0.27450980390000002" green="0.54901960780000003" blue="0.7843137255" alpha="1" colorSpace="calibratedRGB"/>
<accessibility key="accessibilityConfiguration" identifier="addServer"/>
<constraints>
Expand All @@ -65,20 +65,21 @@
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="1000" verticalHuggingPriority="1000" verticalCompressionResistancePriority="1000" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IEC-5d-Hb5">
<rect key="frame" x="0.0" y="217" width="241.5" height="41"/>
<rect key="frame" x="0.0" y="217" width="240" height="41"/>
<string key="text">Thanks for choosing ownCloud!
Start by adding your server.</string>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="x7I-De-RhT" customClass="VectorImageView" customModule="ownCloudAppShared">
<rect key="frame" x="0.0" y="0.0" width="241.5" height="128"/>
<rect key="frame" x="0.0" y="0.0" width="240" height="128"/>
<accessibility key="accessibilityConfiguration">
<accessibilityTraits key="traits" notEnabled="YES"/>
</accessibility>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="xJw-Td-7h2"/>
<constraints>
<constraint firstItem="IEC-5d-Hb5" firstAttribute="centerX" secondItem="PJc-v9-DYn" secondAttribute="centerX" id="5VX-tG-MwV"/>
<constraint firstItem="c8n-gy-7HF" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="xJw-Td-7h2" secondAttribute="leading" id="9hZ-i6-GgM"/>
Expand All @@ -102,18 +103,22 @@ Start by adding your server.</string>
<constraint firstItem="c8n-gy-7HF" firstAttribute="centerX" secondItem="PJc-v9-DYn" secondAttribute="centerX" id="u0i-ca-Uiz"/>
<constraint firstItem="Jaa-D8-ghC" firstAttribute="top" secondItem="IEC-5d-Hb5" secondAttribute="bottom" constant="25" id="wen-iH-60d"/>
</constraints>
<viewLayoutGuide key="safeArea" id="xJw-Td-7h2"/>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="hcy-2V-cIV"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="PJc-v9-DYn" firstAttribute="centerY" secondItem="T7c-kV-xII" secondAttribute="centerY" id="5HM-DO-dRS"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="PJc-v9-DYn" secondAttribute="trailing" constant="20" id="6Sa-PH-mEP"/>
<constraint firstItem="PJc-v9-DYn" firstAttribute="centerX" secondItem="T7c-kV-xII" secondAttribute="centerX" id="87f-aj-n0g"/>
<constraint firstItem="PJc-v9-DYn" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="T7c-kV-xII" secondAttribute="leading" constant="20" id="oMp-WQ-Udb"/>
</constraints>
<viewLayoutGuide key="safeArea" id="hcy-2V-cIV"/>
<point key="canvasLocation" x="-997" y="370"/>
</view>
</objects>
<designables>
<designable name="Jaa-D8-ghC">
<size key="intrinsicContentSize" width="131" height="43"/>
</designable>
</designables>
</document>
21 changes: 18 additions & 3 deletions ownCloud/Static Login/Interface/StaticLoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ class StaticLoginViewController: UIViewController, Themeable {
self.navigationController?.setToolbarHidden(!toolbarShown, animated: true)
}
}
init(with staticLoginBundle: StaticLoginBundle) {

var ignoreExistingBookmarks: Bool

init(with staticLoginBundle: StaticLoginBundle, ignore existing: Bool = false) {
loginBundle = staticLoginBundle
ignoreExistingBookmarks = existing

super.init(nibName: nil, bundle: nil)
}
Expand Down Expand Up @@ -184,7 +188,16 @@ class StaticLoginViewController: UIViewController, Themeable {
}

self.navigationController?.toolbar.isTranslucent = false
self.toolbarShown = true
if !ignoreExistingBookmarks {
self.toolbarShown = true

} else {
self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(dismissView))
}
}

@objc func dismissView() {
self.dismiss(animated: true, completion: nil)
}

override func viewWillAppear(_ animated: Bool) {
Expand All @@ -209,9 +222,11 @@ class StaticLoginViewController: UIViewController, Themeable {
@objc func showFirstScreen() {
var firstViewController : UIViewController?

if OCBookmarkManager.shared.bookmarks.count > 0 {
if OCBookmarkManager.shared.bookmarks.count > 0, !ignoreExistingBookmarks {
// Login selection view
firstViewController = self.buildBookmarkSelector()
} else if OCBookmarkManager.shared.bookmarks.count > 0, ignoreExistingBookmarks {
self.dismiss(animated: true, completion: nil)
} else {
// Setup flow
if loginBundle.profiles.count > 1 {
Expand Down