Skip to content

Commit

Permalink
[fix/branding refinement] Branding: Color and UI Improvements (#1057)
Browse files Browse the repository at this point in the history
* Fixed branding issues

* - fixed default searchBar background and placeholder text color for branded builds
- show single account server list, if only one account is configured for branded and unbranded builds

* - fixed default (unselected) tab bar color
- added table view section border to branded account table view

* - fixed rounded border for text fields in branded login UI
- removed table row separator in branding login view
- fixed colors in contrast mode, if tint color is white
- fixed UIAlertView tint color

* fixed tint color in UIAlertController in dark mode for branding colors

* fixed color value again

* fixed tint color in single account server list cell view

* fixed missing profile UI

* removed optional branding values (only two color values are now needed for a complete branding, all other values are optional)

* fixed border color in single account server view, if navigationbar background color is white

* added gomplate template for Branding.plist creation to the iOS repo
adopted template for new Parameter and removed default values i template

* fixed some color issues, if tint color is white

* fixed setting custom UISearchBar backgroundColor on iOS 12

* set profile url as prefilled default value into setup url field

* added a new color style loginStatusBarStyle to set a custom status bar style for the login view

* if the key app.version-number exists, fastlane will use this value as app and extension short version number, which gives the possibility to set custom version numbers

* Fixed CR findings:
- added a protocol for setting the custom status bar style, instead of using static class names
- using the correct SDK method for round rect

* fixed merge error
  • Loading branch information
hosy authored Nov 12, 2021
1 parent c935375 commit fa81414
Show file tree
Hide file tree
Showing 22 changed files with 540 additions and 114 deletions.
98 changes: 98 additions & 0 deletions enterprise/gomplate/Branding.plist.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?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">{{- $config := .config }}
{{- $hasThemeDefinitionsStyles := false }}
{{- $hasThemeNavigationColors := false }}
{{- $hasThemeSearchColors := false }}
{{- $hasDarkColor := false }}
{{- $hasLightColor := false }}
{{- $darkColor := "" }}
{{- $lightColor := "" }}
{{- $brandingStyle := "" }}
{{- $brandingNavigationStyle := "" }}
<dict>
{{- range $key, $value := $config }}
{{- if eq (printf "%T" $value) "<nil>"}}
{{- if strings.HasSuffix "_check" $key }}
{{$value = false }}
{{- else if strings.HasSuffix "_text" $key }}
{{$value = "" }}
{{- end }}{{- end }}
{{- if hasPrefix $key "ios_branding" }}
{{- if $key | strings.Contains "ios_branding.theme-definitions$[0].darkBrandColor_color" }}
{{ $darkColor = $value }}
{{- else if $key | strings.Contains "ios_branding.theme-definitions$[0].lightBrandColor_color" }}
{{ $lightColor = $value }}
{{- else if $key | strings.Contains "ios_branding.style_select" }}
{{ $brandingStyle = $value }}
{{- else if $key | strings.Contains "ios_branding.navigation.style_select" }}
{{ $brandingNavigationStyle = $value }}
{{- else }}
<key>{{ $key | strings.TrimPrefix "ios_" | strings.TrimSuffix "_check" | strings.TrimSuffix "_text" | strings.TrimSuffix "_color" }}</key>
{{- if eq (printf "%T" $value) "string"}}
<string>{{$value}}</string>
{{- else if eq $value true}}
<true/>
{{- else if eq $value false}}
<false/>{{end}}{{end}}{{end}}
{{- if hasPrefix $key "ios_json_override_longtext"}}
{{- if $value | strings.Contains "branding.theme-definitions" }}
{{- if $value | strings.Contains ".Styles." }}
{{ $hasThemeDefinitionsStyles = true}}
{{end}}
{{- if $value | strings.Contains ".Colors.NavigationBar." }}
{{ $hasThemeNavigationColors = true}}
{{end}}
{{- if $value | strings.Contains ".Colors.Searchbar." }}
{{ $hasThemeSearchColors = true}}
{{end}}
{{end}}
{{- if $value | strings.Contains "branding.theme-definitions$[0].darkBrandColor" }}
{{ $hasDarkColor = true }}{{end}}
{{- if $value | strings.Contains "branding.theme-definitions$[0].lightBrandColor" }}
{{ $hasLightColor = true }}{{end}}
{{$value}}{{end}}{{end}}
{{- if $brandingNavigationStyle | strings.Contains "bright" }}
{{- if eq $hasThemeSearchColors false }}
<key>branding.theme-definitions$[0].Colors.Searchbar.tintColor</key>
<string>#666666</string>
<key>branding.theme-definitions$[0].Colors.Searchbar.secondaryLabelColor</key>
<string>#666666</string>
<key>branding.theme-definitions$[0].Colors.Searchbar.backgroundColor</key>
<string>#F2F2F3</string>
<key>branding.theme-definitions$[0].Colors.Searchbar.labelColor</key>
<string>#000000</string>
{{end}}
{{- if eq $hasThemeNavigationColors false }}
<key>branding.theme-definitions$[0].Colors.NavigationBar.tintColor</key>
<string>{{$darkColor}}</string>
<key>branding.theme-definitions$[0].Colors.NavigationBar.backgroundColor</key>
<string>#FFFFFF</string>
<key>branding.theme-definitions$[0].Colors.NavigationBar.labelColor</key>
<string>#000000</string>
{{end}}{{- end }}
{{- if eq $hasThemeDefinitionsStyles false }}
{{- if $brandingStyle | strings.Contains "dark" }}
<key>branding.theme-definitions$[0].Styles.searchBarActivityIndicatorViewStyle</key>
<string>gray</string>
<key>branding.theme-definitions$[0].Styles.statusBarStyle</key>
<string>lightContent</string>
<key>branding.theme-definitions$[0].Styles.backgroundBlurEffectStyle</key>
<string>dark</string>
<key>branding.theme-definitions$[0].Styles.interfaceStyle</key>
<string>dark</string>
<key>branding.theme-definitions$[0].Styles.keyboardAppearance</key>
<string>dark</string>
<key>branding.theme-definitions$[0].Styles.activityIndicatorViewStyle</key>
<string>white</string>
<key>branding.theme-definitions$[0].Styles.barStyle</key>
<string>default</string>
{{- end }}{{end}}
{{- if eq $hasDarkColor false }}
<key>branding.theme-definitions$[0].darkBrandColor</key>
<string>{{$darkColor}}</string>{{end}}
{{- if eq $hasLightColor false }}
<key>branding.theme-definitions$[0].lightBrandColor</key>
<string>{{$lightColor}}</string>{{end}}
</dict>
</plist>
17 changes: 17 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,20 @@ end
set_info_plist_value(path: "ownCloud/Resources/Info.plist", key: "CFBundleDisplayName", value: appName)
set_info_plist_value(path: "ownCloud/Resources/Info.plist", key: "CFBundleName", value: appName)

if File.exist?("../" + themePath)
tmpCustomAppVersionNumber = get_info_plist_value(path: themePath, key: "app.version-number")
if tmpCustomAppVersionNumber && !tmpCustomAppVersionNumber.empty?
customAppVersionNumber = tmpCustomAppVersionNumber

puts "Set Version Number from Branding.plist: " + customAppVersionNumber
set_info_plist_value(path: "ownCloud/Resources/Info.plist", key: "CFBundleShortVersionString", value: customAppVersionNumber)
set_info_plist_value(path: "ownCloud File Provider/Info.plist", key: "CFBundleShortVersionString", value: customAppVersionNumber)
set_info_plist_value(path: "ownCloud File Provider UI/Info.plist", key: "CFBundleShortVersionString", value: customAppVersionNumber)
set_info_plist_value(path: "ownCloud Share Extension/Info.plist", key: "CFBundleShortVersionString", value: customAppVersionNumber)
set_info_plist_value(path: "ownCloud Intents/Info.plist", key: "CFBundleShortVersionString", value: customAppVersionNumber)
end
end

if !values[:BUILD_NUMBER].nil?
puts "Set Drone Build Number: " + BUILD_NUMBER
set_info_plist_value(path: "ownCloud/Resources/Info.plist", key: "CFBundleVersion", value: BUILD_NUMBER)
Expand Down Expand Up @@ -715,6 +729,9 @@ end
elsif
time = Time.now
ipaSuffix = EXPORT_METHOD + "-" + time.strftime("%Y%m%d-%k%M")
if !customAppVersionNumber.nil?
version = customAppVersionNumber
end
if !values[:BUILD_NUMBER].nil?
version += "." + BUILD_NUMBER
end
Expand Down
10 changes: 9 additions & 1 deletion ownCloud/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
navigationController?.setNavigationBarHidden(true, animated: false)
rootViewController = navigationController
} else {
serverListTableViewController = ServerListTableViewController(style: .plain)
if OCBookmarkManager.shared.bookmarks.count == 1 {
if #available(iOS 13.0, *) {
serverListTableViewController = StaticLoginSingleAccountServerListViewController(style: .insetGrouped)
} else {
serverListTableViewController = StaticLoginSingleAccountServerListViewController(style: .grouped)
}
} else {
serverListTableViewController = ServerListTableViewController(style: .plain)
}

navigationController = ThemeNavigationController(rootViewController: serverListTableViewController!)
rootViewController = navigationController
Expand Down
10 changes: 9 additions & 1 deletion ownCloud/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
navigationController = ThemeNavigationController(rootViewController: staticLoginViewController)
navigationController?.setNavigationBarHidden(true, animated: false)
} else {
let serverListTableViewController = ServerListTableViewController(style: .plain)
var serverListTableViewController : ServerListTableViewController?
if OCBookmarkManager.shared.bookmarks.count == 1 {
serverListTableViewController = StaticLoginSingleAccountServerListViewController(style: .insetGrouped)
} else {
serverListTableViewController = ServerListTableViewController(style: .plain)
}

guard let serverListTableViewController = serverListTableViewController else { return }

serverListTableViewController.restorationIdentifier = "ServerListTableViewController"

navigationController = ThemeNavigationController(rootViewController: serverListTableViewController)
Expand Down
8 changes: 6 additions & 2 deletions ownCloud/Server List/ServerListBookmarkCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ class ServerListBookmarkCell : ThemeTableViewCell {

self.titleLabel.applyThemeCollection(collection, itemStyle: .title, itemState: itemState)
self.detailLabel.applyThemeCollection(collection, itemStyle: .message, itemState: itemState)
self.iconView.image = self.iconView.image?.tinted(with: collection.tableRowColors.labelColor)
if !VendorServices.shared.isBranded {
self.iconView.image = self.iconView.image?.tinted(with: collection.tableRowColors.labelColor)
}
}

override func applyThemeCollection(theme: Theme, collection: ThemeCollection, event: ThemeEvent) {
Expand All @@ -174,6 +176,8 @@ class ServerListBookmarkCell : ThemeTableViewCell {

self.titleLabel.applyThemeCollection(collection, itemStyle: .title, itemState: itemState)
self.detailLabel.applyThemeCollection(collection, itemStyle: .message, itemState: itemState)
self.iconView.image = self.iconView.image?.tinted(with: collection.tableRowColors.labelColor)
if !VendorServices.shared.isBranded {
self.iconView.image = self.iconView.image?.tinted(with: collection.tableRowColors.labelColor)
}
}
}
22 changes: 20 additions & 2 deletions ownCloud/Server List/ServerListTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class ServerListTableViewController: UITableViewController, Themeable, StateRest

// MARK: - Actions
@IBAction func addBookmark() {
showBookmarkUI()
showBookmarkUI(attemptLoginOnSuccess: true)
}

func showBookmarkUI(edit bookmark: OCBookmark? = nil, performContinue: Bool = false, attemptLoginOnSuccess: Bool = false, autosolveErrorOnSuccess: NSError? = nil, removeAuthDataFromCopy: Bool = true) {
Expand All @@ -395,6 +395,7 @@ class ServerListTableViewController: UITableViewController, Themeable, StateRest
if attemptLoginOnSuccess {
bookmarkViewController.userActionCompletionHandler = { [weak self] (bookmark, success) in
if success, let bookmark = bookmark, let self = self {
self.didUpdateServerList()
if let error = autosolveErrorOnSuccess as Error? {
OCMessageQueue.global.resolveIssues(forError: error, forBookmarkUUID: bookmark.uuid)
}
Expand Down Expand Up @@ -646,6 +647,21 @@ class ServerListTableViewController: UITableViewController, Themeable, StateRest

func didUpdateServerList() {
// This is a hook for subclasses

if !VendorServices.shared.isBranded {
if OCBookmarkManager.shared.bookmarks.count == 1 {
var serverListTableViewController : ServerListTableViewController?
if #available(iOS 13.0, *) {
serverListTableViewController = StaticLoginSingleAccountServerListViewController(style: .insetGrouped)
} else {
serverListTableViewController = StaticLoginSingleAccountServerListViewController(style: .grouped)
}

guard let serverListTableViewController = serverListTableViewController else { return }

self.navigationController?.setViewControllers([ serverListTableViewController ], animated: false)
}
}
}

var clientViewController : ClientRootViewController? {
Expand Down Expand Up @@ -743,6 +759,7 @@ class ServerListTableViewController: UITableViewController, Themeable, StateRest
self.tableView.deleteRows(at: [indexPath], with: UITableView.RowAnimation.fade)
}, completion: { (_) in
self.ignoreServerListChanges = false
self.didUpdateServerList()
})
}
}
Expand Down Expand Up @@ -808,7 +825,8 @@ class ServerListTableViewController: UITableViewController, Themeable, StateRest
self.tableView.deleteRows(at: [indexPath], with: UITableView.RowAnimation.fade)
}
}, completion: { (_) in
self.ignoreServerListChanges = false
self.ignoreServerListChanges = false
self.didUpdateServerList()
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class StaticLoginServerListViewController: ServerListTableViewController {
}
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

staticLoginViewController?.navigationController?.setNeedsStatusBarAppearanceUpdate()
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)

Expand Down Expand Up @@ -79,6 +85,12 @@ class StaticLoginServerListViewController: ServerListTableViewController {
return bookmarkCell
}

override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if VendorServices.shared.isBranded {
self.colorSection(tableView, willDisplay: cell, forRowAt: indexPath, borderColor: Theme.shared.activeCollection.navigationBarColors.backgroundColor)
}
}

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if headerView == nil {
headerView = StaticTableViewSection.buildHeader(title: "Accounts".localized)
Expand All @@ -98,9 +110,7 @@ class StaticLoginServerListViewController: ServerListTableViewController {
}

override func didUpdateServerList() {
if OCBookmarkManager.shared.bookmarks.count == 0 {
self.staticLoginViewController?.showFirstScreen()
}
self.staticLoginViewController?.showFirstScreen()
}

override func applyThemeCollection(theme: Theme, collection: ThemeCollection, event: ThemeEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ class StaticLoginSetupViewController : StaticLoginStepViewController {
override func viewDidLoad() {
super.viewDidLoad()

self.tableView.separatorStyle = .none

if profile.canConfigureURL {
self.urlString = profile.url?.absoluteString
self.addSection(urlSection())
if OCBookmarkManager.shared.bookmarks.count == 0, profile.isOnboardingEnabled {
self.addSection(onboardingSection())
Expand Down Expand Up @@ -121,7 +124,7 @@ class StaticLoginSetupViewController : StaticLoginStepViewController {
if let value = row.value as? String {
self?.username = value
}
}, placeholder: "Username".localized, keyboardType: .asciiCapable, autocorrectionType: .no, autocapitalizationType: .none, returnKeyType: .continue, identifier: "username"))
}, placeholder: "Username".localized, keyboardType: .asciiCapable, autocorrectionType: .no, autocapitalizationType: .none, returnKeyType: .continue, identifier: "username", borderStyle: .roundedRect))

passwordRow = StaticTableViewRow(secureTextFieldWithAction: { [weak self] (row, _, type) in
if type == .didBegin, let cell = row.cell, let indexPath = self?.tableView.indexPath(for: cell) {
Expand All @@ -133,7 +136,7 @@ class StaticLoginSetupViewController : StaticLoginStepViewController {
if type == .didReturn, let value = row.value as? String, value.count > 0 {
self?.startAuthentication(nil)
}
}, placeholder: "Password".localized, keyboardType: .asciiCapable, autocorrectionType: .no, autocapitalizationType: .none, returnKeyType: .continue, identifier: "password")
}, placeholder: "Password".localized, keyboardType: .asciiCapable, autocorrectionType: .no, autocapitalizationType: .none, returnKeyType: .continue, identifier: "password", borderStyle: .roundedRect)
if let passwordRow = passwordRow {
loginMaskSection.add(row: passwordRow)
}
Expand Down Expand Up @@ -289,7 +292,9 @@ class StaticLoginSetupViewController : StaticLoginStepViewController {
guard self.bookmark != nil else {
let alertController = ThemedAlertController(title: "Missing Profile URL".localized, message: String(format: "The Profile '%@' does not have a URL configured.\nPlease provide a URL via configuration or MDM.".localized, profile.name ?? ""), preferredStyle: .alert)

alertController.addAction(UIAlertAction(title: "OK".localized, style: .default, handler: nil))
alertController.addAction(UIAlertAction(title: "OK".localized, style: .default, handler: { _ in
self.popViewController()
}))

self.loginViewController?.present(alertController, animated: true, completion: nil)
return
Expand Down
Loading

0 comments on commit fa81414

Please sign in to comment.