Skip to content
Snippets Groups Projects
Commit bf410e23 authored by lazarog98's avatar lazarog98
Browse files

#238 move the string process method to a helper class

parent 9cd4a60f
No related branches found
No related tags found
1 merge request!27Resolve "Improve searching"
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
0E6551A72406A42300DE30FC /* SearchHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E6551A62406A42300DE30FC /* SearchHelper.swift */; };
3E6B07DE2011246500E49609 /* invitationText.html in Resources */ = {isa = PBXBuildFile; fileRef = 3E6B07DD2011246500E49609 /* invitationText.html */; }; 3E6B07DE2011246500E49609 /* invitationText.html in Resources */ = {isa = PBXBuildFile; fileRef = 3E6B07DD2011246500E49609 /* invitationText.html */; };
3EB4FA9F2012007C001D0625 /* DialogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EB4FA9D2012007C001D0625 /* DialogViewController.swift */; }; 3EB4FA9F2012007C001D0625 /* DialogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EB4FA9D2012007C001D0625 /* DialogViewController.swift */; };
3EB4FAA12012007C001D0625 /* Dialog.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3EB4FA9E2012007C001D0625 /* Dialog.storyboard */; }; 3EB4FAA12012007C001D0625 /* Dialog.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3EB4FA9E2012007C001D0625 /* Dialog.storyboard */; };
...@@ -257,6 +258,7 @@ ...@@ -257,6 +258,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
0E6551A62406A42300DE30FC /* SearchHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchHelper.swift; sourceTree = "<group>"; };
1D4A9E60565DECF52C011BC0 /* Pods-enzevalos_iphone-AdHoc.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphone-AdHoc.release.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphone-AdHoc/Pods-enzevalos_iphone-AdHoc.release.xcconfig"; sourceTree = "<group>"; }; 1D4A9E60565DECF52C011BC0 /* Pods-enzevalos_iphone-AdHoc.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphone-AdHoc.release.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphone-AdHoc/Pods-enzevalos_iphone-AdHoc.release.xcconfig"; sourceTree = "<group>"; };
3E6B07DD2011246500E49609 /* invitationText.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = invitationText.html; path = Invitation/invitationText.html; sourceTree = "<group>"; }; 3E6B07DD2011246500E49609 /* invitationText.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = invitationText.html; path = Invitation/invitationText.html; sourceTree = "<group>"; };
3E9708AD1FAC925D005825C9 /* enzevalos_iphone.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = enzevalos_iphone.entitlements; sourceTree = "<group>"; }; 3E9708AD1FAC925D005825C9 /* enzevalos_iphone.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = enzevalos_iphone.entitlements; sourceTree = "<group>"; };
...@@ -1128,6 +1130,7 @@ ...@@ -1128,6 +1130,7 @@
A1EB05971D956947008659C1 /* InboxViewController.swift */, A1EB05971D956947008659C1 /* InboxViewController.swift */,
F120607F1DA540FE00F6EF37 /* RefreshControlExtension.swift */, F120607F1DA540FE00F6EF37 /* RefreshControlExtension.swift */,
A1F9923B1DA7DD2E0073BF1B /* InboxTableViewCell.xib */, A1F9923B1DA7DD2E0073BF1B /* InboxTableViewCell.xib */,
0E6551A62406A42300DE30FC /* SearchHelper.swift */,
); );
name = inbox; name = inbox;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -1615,6 +1618,7 @@ ...@@ -1615,6 +1618,7 @@
472F39701E14F75C009260FB /* DataHandler.swift in Sources */, 472F39701E14F75C009260FB /* DataHandler.swift in Sources */,
A1C62E9A2018F716000E5273 /* OnboardingValueState.swift in Sources */, A1C62E9A2018F716000E5273 /* OnboardingValueState.swift in Sources */,
A1EB05901D956923008659C1 /* ReadViewController.swift in Sources */, A1EB05901D956923008659C1 /* ReadViewController.swift in Sources */,
0E6551A72406A42300DE30FC /* SearchHelper.swift in Sources */,
472F398E1E251B8D009260FB /* MailAddress.swift in Sources */, 472F398E1E251B8D009260FB /* MailAddress.swift in Sources */,
A198D2292056B384004CC838 /* SendViewDelegate.swift in Sources */, A198D2292056B384004CC838 /* SendViewDelegate.swift in Sources */,
479011492289975D0057AB04 /* NoSecIconStyleKit.swift in Sources */, 479011492289975D0057AB04 /* NoSecIconStyleKit.swift in Sources */,
......
This diff is collapsed.
...@@ -267,40 +267,12 @@ class InboxViewController: UITableViewController, InboxCellDelegator { ...@@ -267,40 +267,12 @@ class InboxViewController: UITableViewController, InboxCellDelegator {
} }
} }
/**
Function to be used to find mails that contain the search terms. All terms (separated by spaces) need to be contained in the search text.
- parameters:
- content: The String that will be searched
- searchText: Search terms (space-separated) that will be searched for
*/
private func containsSearchTerms ( content : String?, searchText: String) -> Bool
{
if searchText == ""
{
return true ///Case empty search
}
if content == nil
{
return false ///Case Mail has no body/subject
}
let terms = searchText.lowercased().components(separatedBy : " ")
var found = true
for t in terms
{
//print("term is: |"+t+"|")
if !(t == "")
{
found = found && content!.lowercased().contains(t)
}
}
return found
}
/** /**
Filters emails by a user input string and scope Filters emails by a user input string and scope
- parameters: - parameters:
-scope: 0 = - scope: 0 = contact name; 1 = subject; 2 = body; 3 = all
- searchText: the string we are looking for
*/ */
private func _filterContentForSearchText(_ searchText: String, scope: Int = 0) { private func _filterContentForSearchText(_ searchText: String, scope: Int = 0) {
var records = [KeyRecord]() var records = [KeyRecord]()
......
//
// SearchHelper.swift
// enzevalos_iphone
//
// Created by lazarog98 on 26.02.20.
// Copyright © 2020 fu-berlin. All rights reserved.
//
import Foundation
/**
Function to be used to find mails that contain the search terms. All terms (separated by spaces) need to be contained in the search text.
- parameters:
- content: The String that will be searched
- searchText: Search terms (space-separated) that will be searched for
*/
func containsSearchTerms ( content : String?, searchText: String) -> Bool
{
if searchText == ""
{
return true ///Case empty search
}
if content == nil
{
return false ///Case Mail has no body/subject
}
let terms = searchText.lowercased().components(separatedBy : " ")
var found = true
for t in terms
{
//print("term is: |"+t+"|")
if !(t == "")
{
found = found && content!.lowercased().contains(t)
}
}
return found
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment