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

Commit

Permalink
Fix #2476, Fix #2477: Publisher list parsing & memory improvements (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson committed Apr 22, 2020
1 parent 1ba2194 commit f987e5b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
Binary file modified BraveRewards/BraveRewards.framework/BraveRewards
Binary file not shown.
2 changes: 2 additions & 0 deletions BraveRewards/BraveRewards.framework/Headers/BATBraveLedger.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ NS_SWIFT_NAME(BraveLedger)
@property (nonatomic, assign) double contributionAmount;
/// Whether or not the user will automatically contribute
@property (nonatomic, assign, getter=isAutoContributeEnabled) BOOL autoContributeEnabled;
/// A custom user agent for network operations on ledger
@property (nonatomic, copy, nullable) NSString *customUserAgent;

#pragma mark - Ads & Confirmations

Expand Down
29 changes: 28 additions & 1 deletion BraveRewardsUI/QA Settings/QASettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public class QASettingsViewController: TableViewController {
$0.placeholder = "0"
}

private let customUserAgentTextField = UITextField().then {
$0.borderStyle = .roundedRect
$0.autocorrectionType = .no
$0.autocapitalizationType = .none
$0.spellCheckingType = .no
$0.returnKeyType = .done
$0.textAlignment = .right
}

@objc private func reconcileTimeEditingEnded() {
guard let value = Int32(reconcileTimeTextField.text ?? "") else {
let alert = UIAlertController(title: "Invalid value", message: "Time has been reset to 0 (no override)", preferredStyle: .alert)
Expand Down Expand Up @@ -76,6 +85,10 @@ public class QASettingsViewController: TableViewController {
Preferences.Rewards.adsDurationOverride.value = value > 0 ? value : nil
}

@objc private func customUserAgentEditingEnded() {
rewards.ledger.customUserAgent = customUserAgentTextField.text
}

private var numpadDismissalToolbar: UIToolbar {
return UIToolbar().then {
$0.items = [
Expand Down Expand Up @@ -111,6 +124,12 @@ public class QASettingsViewController: TableViewController {
adsDismissalTextField.inputAccessoryView = numpadDismissalToolbar
adsDismissalTextField.text = "\(Preferences.Rewards.adsDurationOverride.value ?? 0)"

customUserAgentTextField.addTarget(self, action: #selector(customUserAgentEditingEnded), for: .editingDidEnd)
customUserAgentTextField.delegate = self
customUserAgentTextField.frame = CGRect(x: 0, y: 0, width: 125, height: 32)
customUserAgentTextField.inputAccessoryView = numpadDismissalToolbar
customUserAgentTextField.text = rewards.ledger.customUserAgent

KeyboardHelper.defaultHelper.addDelegate(self)

dataSource.sections = [
Expand All @@ -132,7 +151,8 @@ public class QASettingsViewController: TableViewController {
Row(text: "Use Short Retries", accessory: .switchToggle(value: BraveLedger.useShortRetries, { value in
BraveLedger.useShortRetries = value
})),
Row(text: "Reconcile Time", detailText: "Number of minutes between reconciles. 0 = No Override", accessory: .view(reconcileTimeTextField), cellClass: MultilineSubtitleCell.self)
Row(text: "Reconcile Time", detailText: "Number of minutes between reconciles. 0 = No Override", accessory: .view(reconcileTimeTextField), cellClass: MultilineSubtitleCell.self),
Row(text: "Custom User Agent", detailText: "Non-persistant. Empty = default", accessory: .view(customUserAgentTextField), cellClass: MultilineSubtitleCell.self)
]
),
Section(
Expand Down Expand Up @@ -281,6 +301,13 @@ extension QASettingsViewController: KeyboardHelperDelegate {
}
}

extension QASettingsViewController: UITextFieldDelegate {
public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
}

fileprivate class MultilineSubtitleCell: SubtitleCell {

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
Expand Down
2 changes: 1 addition & 1 deletion BraveRewardsUI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ The latest BraveRewards.framework was built on:

```
brave-browser/f3abb85e967fbddd9dcd9447b114446cf9450669
brave-core/6f35c9d313c4bf0b73fadd79593e487bb4143b6b
brave-core/51281fdfcdad99d2d09f4b3476ec1b2cac733c9a
```

0 comments on commit f987e5b

Please sign in to comment.