forked from shadowfacts/Tusker
Add option to attempt to open links in their respective apps
This commit is contained in:
parent
779f04b62f
commit
3366b16c96
|
@ -38,9 +38,10 @@ class Preferences: Codable {
|
||||||
var avatarStyle = AvatarStyle.roundRect
|
var avatarStyle = AvatarStyle.roundRect
|
||||||
var hideCustomEmojiInUsernames = false
|
var hideCustomEmojiInUsernames = false
|
||||||
|
|
||||||
|
// MARK: - Behavior
|
||||||
var defaultPostVisibility = Status.Visibility.public
|
var defaultPostVisibility = Status.Visibility.public
|
||||||
|
|
||||||
var automaticallySaveDrafts = true
|
var automaticallySaveDrafts = true
|
||||||
|
var openLinksInApps = true
|
||||||
|
|
||||||
// MARK: - Advanced
|
// MARK: - Advanced
|
||||||
var silentActions: [String: Permission] = [:]
|
var silentActions: [String: Permission] = [:]
|
||||||
|
|
|
@ -12,16 +12,14 @@ class BehaviorTableViewController: UITableViewController {
|
||||||
|
|
||||||
@IBOutlet weak var defaultPostVisibilityLabel: UILabel!
|
@IBOutlet weak var defaultPostVisibilityLabel: UILabel!
|
||||||
@IBOutlet weak var automaticallySaveDraftsSwitch: UISwitch!
|
@IBOutlet weak var automaticallySaveDraftsSwitch: UISwitch!
|
||||||
|
@IBOutlet weak var openLinksInAppsSwitch: UISwitch!
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
defaultPostVisibilityLabel.text = Preferences.shared.defaultPostVisibility.displayName
|
defaultPostVisibilityLabel.text = Preferences.shared.defaultPostVisibility.displayName
|
||||||
automaticallySaveDraftsSwitch.setOn(Preferences.shared.automaticallySaveDrafts, animated: false)
|
automaticallySaveDraftsSwitch.setOn(Preferences.shared.automaticallySaveDrafts, animated: false)
|
||||||
}
|
openLinksInAppsSwitch.setOn(Preferences.shared.openLinksInApps, animated: false)
|
||||||
|
|
||||||
@IBAction func automaticallySaveDraftsChanged(_ sender: Any) {
|
|
||||||
Preferences.shared.automaticallySaveDrafts = automaticallySaveDraftsSwitch.isOn
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
|
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
|
||||||
|
@ -43,4 +41,13 @@ class BehaviorTableViewController: UITableViewController {
|
||||||
present(alertController, animated: true)
|
present(alertController, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func automaticallySaveDraftsChanged(_ sender: Any) {
|
||||||
|
Preferences.shared.automaticallySaveDrafts = automaticallySaveDraftsSwitch.isOn
|
||||||
|
}
|
||||||
|
|
||||||
|
@IBAction func openLinksInAppsChanged(_ sender: Any) {
|
||||||
|
Preferences.shared.openLinksInApps = openLinksInAppsSwitch.isOn
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.30.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="VJJ-jC-9g8">
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.59" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="VJJ-jC-9g8">
|
||||||
<device id="retina4_7" orientation="portrait">
|
<device id="retina4_7" orientation="portrait">
|
||||||
<adaptation id="fullscreen"/>
|
<adaptation id="fullscreen"/>
|
||||||
</device>
|
</device>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.19.1"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.45"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<scenes>
|
<scenes>
|
||||||
|
@ -292,6 +292,39 @@
|
||||||
</tableViewCell>
|
</tableViewCell>
|
||||||
</cells>
|
</cells>
|
||||||
</tableViewSection>
|
</tableViewSection>
|
||||||
|
<tableViewSection id="pnH-qu-zTX">
|
||||||
|
<cells>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" id="A95-CC-eMR">
|
||||||
|
<rect key="frame" x="0.0" y="159" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="A95-CC-eMR" id="0l5-fe-g8R">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Open Links in Apps" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pRl-1e-i4j">
|
||||||
|
<rect key="frame" x="16" y="11.5" width="148" height="21"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="85C-G0-cRk">
|
||||||
|
<rect key="frame" x="310" y="6.5" width="51" height="31"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="automaticallySaveDraftsChanged:" destination="Nk9-yO-78a" eventType="valueChanged" id="3jl-gq-XEX"/>
|
||||||
|
<action selector="openLinksInAppsChanged:" destination="Nk9-yO-78a" eventType="valueChanged" id="THd-FD-XYN"/>
|
||||||
|
</connections>
|
||||||
|
</switch>
|
||||||
|
</subviews>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="85C-G0-cRk" firstAttribute="centerY" secondItem="0l5-fe-g8R" secondAttribute="centerY" id="QuM-P5-nPV"/>
|
||||||
|
<constraint firstItem="pRl-1e-i4j" firstAttribute="leading" secondItem="0l5-fe-g8R" secondAttribute="leadingMargin" id="Xqp-IO-EiQ"/>
|
||||||
|
<constraint firstAttribute="trailingMargin" secondItem="85C-G0-cRk" secondAttribute="trailing" id="bKz-K4-r5w"/>
|
||||||
|
<constraint firstItem="pRl-1e-i4j" firstAttribute="centerY" secondItem="0l5-fe-g8R" secondAttribute="centerY" id="ns6-xZ-q0A"/>
|
||||||
|
</constraints>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
</cells>
|
||||||
|
</tableViewSection>
|
||||||
</sections>
|
</sections>
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="dataSource" destination="Nk9-yO-78a" id="bN3-mz-nCZ"/>
|
<outlet property="dataSource" destination="Nk9-yO-78a" id="bN3-mz-nCZ"/>
|
||||||
|
@ -302,6 +335,7 @@
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="automaticallySaveDraftsSwitch" destination="HV4-3m-Mal" id="eE1-Q4-za9"/>
|
<outlet property="automaticallySaveDraftsSwitch" destination="HV4-3m-Mal" id="eE1-Q4-za9"/>
|
||||||
<outlet property="defaultPostVisibilityLabel" destination="OBq-tA-USG" id="yFX-yQ-dN9"/>
|
<outlet property="defaultPostVisibilityLabel" destination="OBq-tA-USG" id="yFX-yQ-dN9"/>
|
||||||
|
<outlet property="openLinksInAppsSwitch" destination="85C-G0-cRk" id="2lR-Jb-O6K"/>
|
||||||
</connections>
|
</connections>
|
||||||
</tableViewController>
|
</tableViewController>
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="YN6-Jb-XJJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
<placeholder placeholderIdentifier="IBFirstResponder" id="YN6-Jb-XJJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
|
|
@ -60,7 +60,15 @@ extension TuskerNavigationDelegate where Self: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
func selected(url: URL) {
|
func selected(url: URL) {
|
||||||
present(SFSafariViewController(url: url), animated: true)
|
if (Preferences.shared.openLinksInApps) {
|
||||||
|
UIApplication.shared.open(url, options: [.universalLinksOnly: true]) { (success) in
|
||||||
|
if (!success) {
|
||||||
|
self.present(SFSafariViewController(url: url), animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
present(SFSafariViewController(url: url), animated: true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func selected(status statusID: String) {
|
func selected(status statusID: String) {
|
||||||
|
|
Loading…
Reference in New Issue