Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Ref #1391: Added preference to customize new bookmark button.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhreis committed Aug 30, 2019
1 parent 2543ce5 commit 08d3e9a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions BraveShared/BraveStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ extension Strings {
public static let Privacy = NSLocalizedString("Privacy", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Privacy", comment: "Settings privacy section title")
public static let Security = NSLocalizedString("Security", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Security", comment: "Settings security section title")
public static let Save_Logins = NSLocalizedString("SaveLogins", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Save Logins", comment: "Setting to enable the built-in password manager")
public static let Show_Bookmark_Button_In_Top_Toolbar = NSLocalizedString("ShowBookmarkButtonInTopToolbar", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Show Bookmarks Shortcut", comment: "Setting to show a bookmark button on the top level menu that triggers a panel of the user's bookmarks.")
public static let AlwaysRequestDesktopSite = NSLocalizedString("AlwaysRequestDesktopSite", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Always request desktop site", comment: "Setting to always request desktop site")
public static let ShieldsAdStats = NSLocalizedString("AdsrBlocked", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Ads \nBlocked", comment: "Shields Ads Stat")
public static let ShieldsAdAndTrackerStats = NSLocalizedString("AdsAndTrackersrBlocked", tableName: "BraveShared", bundle: Bundle.braveShared, value: "Ads & Trackers \nBlocked", comment: "Shields Ads Stat")
Expand Down
2 changes: 2 additions & 0 deletions Client/Application/ClientPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ extension Preferences {
static let blockPopups = Option<Bool>(key: "general.block-popups", default: true)
/// Controls how the tab bar should be shown (or not shown)
static let tabBarVisibility = Option<Int>(key: "general.tab-bar-visiblity", default: TabBarVisibility.always.rawValue)
/// Specifies whether the bookmark button is present on toolbar
static let bookmarkToolbarVisibility = Option<Bool>(key: "general.bookmark-toolbar-visibility", default: false)
/// Sets Desktop UA for iPad by default (iOS 13+ & iPad only)
static let alwaysRequestDesktopSite = Option<Bool>(key: "general.always-request-desktop-site", default: UIDevice.isIpad)

Expand Down
11 changes: 11 additions & 0 deletions Client/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ class TopToolbarView: UIView, ToolbarProtocol {
helper = ToolbarHelper(toolbar: self)
setupConstraints()

Preferences.General.bookmarkToolbarVisibility.observe(from: self)

// Make sure we hide any views that shouldn't be showing in non-overlay mode.
updateViewsForOverlayModeAndToolbarChanges()
}
Expand Down Expand Up @@ -423,6 +425,7 @@ class TopToolbarView: UIView, ToolbarProtocol {
menuButton.isHidden = !toolbarIsShowing || inOverlayMode
tabsButton.isHidden = !toolbarIsShowing || inOverlayMode
locationView.contentView.isHidden = inOverlayMode
bookmarkButton.isHidden = !Preferences.General.bookmarkToolbarVisibility.value
}

private func animateToOverlayState(overlayMode overlay: Bool, didCancel cancel: Bool = false) {
Expand Down Expand Up @@ -473,6 +476,14 @@ class TopToolbarView: UIView, ToolbarProtocol {
}
}

// MARK: - PreferencesObserver

extension TopToolbarView: PreferencesObserver {
func preferencesDidChange(for key: String) {
updateViewsForOverlayModeAndToolbarChanges()
}
}

// MARK: - TabLocationViewDelegate

extension TopToolbarView: TabLocationViewDelegate {
Expand Down
4 changes: 4 additions & 0 deletions Client/Frontend/Settings/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ class SettingsViewController: TableViewController {
general.rows.append(row)
}

general.rows.append(
BoolRow(title: Strings.Show_Bookmark_Button_In_Top_Toolbar, option: Preferences.General.bookmarkToolbarVisibility)
)

if #available(iOS 13.0, *), UIDevice.isIpad {
general.rows.append(BoolRow(title: Strings.AlwaysRequestDesktopSite,
option: Preferences.General.alwaysRequestDesktopSite))
Expand Down

0 comments on commit 08d3e9a

Please sign in to comment.