Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Provide a config which disables the readers UIMenuController #154

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end

def testing_pods
pod 'Quick', '0.9.2'
pod 'Nimble'
pod 'Nimble', '~> 4.1.0'
end

target 'Example' do
Expand Down
20 changes: 10 additions & 10 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ PODS:
- MenuItemKit (1.1.3)
- Nimble (4.1.0)
- Quick (0.9.2)
- Realm (1.0.2):
- Realm/Headers (= 1.0.2)
- Realm/Headers (1.0.2)
- RealmSwift (1.0.2):
- Realm (= 1.0.2)
- Realm (1.1.0):
- Realm/Headers (= 1.1.0)
- Realm/Headers (1.1.0)
- RealmSwift (1.1.0):
- Realm (= 1.1.0)
- SSZipArchive (1.5)
- ZFDragableModalTransition (0.6)

DEPENDENCIES:
- FolioReaderKit (from `../`)
- Nimble
- Nimble (~> 4.1.0)
- Quick (= 0.9.2)

EXTERNAL SOURCES:
FolioReaderKit:
:path: "../"
:path: ../

SPEC CHECKSUMS:
AEXML: 716fb0a8decba4a3517324a71fee3685b30233d2
Expand All @@ -38,11 +38,11 @@ SPEC CHECKSUMS:
MenuItemKit: 11c448d9172936ee79ebb78f36dffd396020a9e5
Nimble: 97a0a4cae5124c117115634b2d055d8c97d0af19
Quick: 18d057bc66451eedd5d1c8dc99ba2a5db6e60226
Realm: 9d5c46a4d7d27958530a8dfc58f63a99e5c2cba3
RealmSwift: 82f3ac5e24530143dddfde2033acc0d308f27d96
Realm: ceecf1a4540c4ce9efe196fe73fa9855bce05bd8
RealmSwift: 838058b2db95b12cb86bd0cf209df642c33fb60a
SSZipArchive: 29daace2bccb90a47de2837744da397728ff9207
ZFDragableModalTransition: 0d294eaaba6edfcb9839595de765f9ca06a4b524

PODFILE CHECKSUM: 019ed1399429245758bdf9b0c090c4b685a25030
PODFILE CHECKSUM: 617d506c4ff6fef0fcf4032d9acdc7ee8ad208e9

COCOAPODS: 1.0.1
5 changes: 4 additions & 1 deletion Source/FolioReaderConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ public class FolioReaderConfig: NSObject {

/// Localizes Content title
public var localizedContentsTitle = NSLocalizedString("Contents", comment: "")


/// Use the readers `UIMenuController` which enables the highlighting etc. The default is `true`. If set to false it's possible to modify the shared `UIMenuController` for yourself. Note: This doesn't disable the text selection in the web view.
public var useReaderMenuController = true

/// Localizes Highlight date format. This is a `dateFormat` from `NSDateFormatter`, so be careful 🤔
public var localizedHighlightsDateFormat = "MMM dd, YYYY | HH:mm"
public var localizedHighlightMenu = NSLocalizedString("Highlight", comment: "")
Expand Down
2 changes: 1 addition & 1 deletion Source/FolioReaderPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ public class FolioReaderPage: UICollectionViewCell, UIWebViewDelegate, UIGesture
// MARK: UIMenu visibility

override public func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
if UIMenuController.sharedMenuController().menuItems?.count == 0 {
if UIMenuController.sharedMenuController().menuItems?.count == 0 {
webView.isColors = false
webView.createMenu(options: false)
}
Expand Down
8 changes: 6 additions & 2 deletions Source/FolioReaderWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

class FolioReaderWebView: UIWebView {
public class FolioReaderWebView: UIWebView {

var isColors = false
var isShare = false
Expand All @@ -17,7 +17,7 @@ class FolioReaderWebView: UIWebView {
// MARK: - UIMenuController

public override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
guard readerConfig != nil else {
guard readerConfig != nil && readerConfig.useReaderMenuController == true else {
return super.canPerformAction(action, withSender: sender)
}

Expand Down Expand Up @@ -177,6 +177,10 @@ class FolioReaderWebView: UIWebView {
// MARK: - Create and show menu

func createMenu(options options: Bool) {
guard readerConfig.useReaderMenuController else {
return
}

isShare = options

let colors = UIImage(readerImageNamed: "colors-marker")
Expand Down