mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-21 23:22:08 +02:00
Merge branch 'feature/4482_feature_banner_link_fix' into 'develop'
MESSENGER-4482 fix feature banner link and add navigationbar See merge request bwmessenger/bundesmessenger/bundesmessenger-ios!116
This commit is contained in:
@@ -192,6 +192,28 @@ class BWIBuildSettings: NSObject {
|
||||
// replace feature history link variable with the appropiate build setting
|
||||
var bwiFeatureHistoryLink = "https://messenger.bwi.de/bwmessenger#c6110"
|
||||
var bwiReplaceFeatureLink = true
|
||||
|
||||
// feature history file path
|
||||
var bwiFeatureHistoryFilePath: String {
|
||||
guard let bundleFileURL = Bundle.main.url(forResource: newFeaturesHTML, withExtension: "html") else {return ""}
|
||||
|
||||
// replace feature link and copy file into document directory
|
||||
if bwiReplaceFeatureLink {
|
||||
if var newFileURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last {
|
||||
newFileURL = newFileURL.appendingPathComponent(newFeaturesHTML.appending(".html"))
|
||||
do {
|
||||
var text = try String(contentsOf: bundleFileURL, encoding: .utf8)
|
||||
text = text.replacingOccurrences(of: "$FEATURELINK", with: bwiFeatureHistoryLink)
|
||||
try text.write(to: newFileURL, atomically: false, encoding: .utf8)
|
||||
|
||||
// return new path
|
||||
return newFileURL.path
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
return bundleFileURL.path
|
||||
}
|
||||
|
||||
// login with matrix id should only be enabled in some configurations
|
||||
var bwiEnableLoginWithMatrixID = true
|
||||
|
||||
@@ -3442,14 +3442,8 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
|
||||
{
|
||||
if (row == SHOW_NEW_FEATURES)
|
||||
{
|
||||
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:BWIBuildSettings.shared.newFeaturesHTML ofType:@"html" inDirectory:nil];
|
||||
// bwi: if enabled replace feature link and use file from document directory
|
||||
if (BWIBuildSettings.shared.bwiReplaceFeatureLink) {
|
||||
BwiNewFeatureHelper *featureHelper = [[BwiNewFeatureHelper alloc] init];
|
||||
[featureHelper replaceFeatureHistoryLink];
|
||||
NSURL *filePath = [featureHelper getDocumentDirectory];
|
||||
htmlFile = [filePath path];
|
||||
}
|
||||
// bwi: replace link and show webview
|
||||
NSString *htmlFile = BWIBuildSettings.shared.bwiFeatureHistoryFilePath;
|
||||
WebViewViewController *webViewViewController = [[WebViewViewController alloc] initWithLocalHTMLFile: htmlFile];
|
||||
webViewViewController.title = BWIL10n.bwiSettingsNewFeaturesHeader;
|
||||
[self pushViewController:webViewViewController];
|
||||
|
||||
@@ -114,10 +114,6 @@
|
||||
[self updateSideMenuNotifcationIcon];
|
||||
}];
|
||||
|
||||
// replace link
|
||||
if (BWIBuildSettings.shared.bwiReplaceFeatureLink) {
|
||||
[[[BwiNewFeatureHelper alloc] init] replaceFeatureHistoryLink];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)userInterfaceThemeDidChange
|
||||
|
||||
@@ -27,6 +27,7 @@ protocol FeatureBannerDelegate {
|
||||
@objcMembers class FeatureBannerViewCell<Content: View>: UITableViewCell, FeatureBannerDelegate {
|
||||
private var parentViewController: UIViewController?
|
||||
private let hostingController = UIHostingController<Content?>(rootView: nil)
|
||||
private var webViewController: WebViewViewController?
|
||||
|
||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
@@ -89,16 +90,19 @@ protocol FeatureBannerDelegate {
|
||||
}
|
||||
|
||||
func didPressShowDetails() {
|
||||
let htmlFile = Bundle.main.path(forResource: BWIBuildSettings.shared.newFeaturesHTML, ofType: "html")
|
||||
if let webviewController = WebViewViewController(localHTMLFile: htmlFile) {
|
||||
webviewController.title = BWIL10n.bwiSettingsNewFeaturesHeader
|
||||
|
||||
hostingController.parent?.present(webviewController, animated: true, completion: { () -> Void in
|
||||
self.hideTopBanner()
|
||||
})
|
||||
}
|
||||
let htmlFile = BWIBuildSettings.shared.bwiFeatureHistoryFilePath
|
||||
self.webViewController = WebViewViewController(localHTMLFile: htmlFile)
|
||||
webViewController?.title = BWIL10n.bwiSettingsNewFeaturesHeader
|
||||
let navigationBar: UINavigationController = UINavigationController(rootViewController: webViewController!)
|
||||
webViewController?.navigationItem.setLeftBarButton(UIBarButtonItem(title: VectorL10n.close, style: .plain, target: self, action: #selector(closeModal)), animated: false)
|
||||
hostingController.parent?.present(navigationBar, animated: true, completion: { () -> Void in
|
||||
self.hideTopBanner()
|
||||
})
|
||||
}
|
||||
|
||||
@objc func closeModal() {
|
||||
webViewController?.dismiss(animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2022 BWI GmbH
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc class BwiNewFeatureHelper: NSObject {
|
||||
|
||||
@objc func replaceFeatureHistoryLink() {
|
||||
guard let urlPath = Bundle.main.url(forResource: BWIBuildSettings.shared.newFeaturesHTML, withExtension: "html") else {
|
||||
return
|
||||
}
|
||||
|
||||
// files in bundle cannot be edited use document directory
|
||||
if let filePath = getDocumentDirectory() {
|
||||
do {
|
||||
var text = try String(contentsOf: urlPath, encoding: .utf8)
|
||||
text = text.replacingOccurrences(of: "$FEATURELINK", with: BWIBuildSettings.shared.bwiFeatureHistoryLink)
|
||||
try text.write(to: filePath, atomically: false, encoding: .utf8)
|
||||
}
|
||||
catch {}
|
||||
} else { return }
|
||||
}
|
||||
|
||||
@objc func getDocumentDirectory() -> URL? {
|
||||
if let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last {
|
||||
return documentDirectory.appendingPathComponent(BWIBuildSettings.shared.newFeaturesHTML.appending(".html"))
|
||||
} else {
|
||||
return Bundle.main.url(forResource: BWIBuildSettings.shared.newFeaturesHTML, withExtension: "html")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user