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

[fix/branding refinement] Branding: Color and UI Improvements #1057

Merged
merged 19 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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