Skip to content

Commit

Permalink
Improve feed parsing and memory consumption on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
prof18 committed Sep 8, 2023
1 parent a938e92 commit 9634325
Show file tree
Hide file tree
Showing 32 changed files with 266 additions and 226 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ lifecycle-runtime-compose = "2.6.1"
kotlinx-serialization = "1.5.1"
org-robolectric = "4.9"
sql-delight = "2.0.0"
rss-parser = "6.0.0"
rss-parser = "6.0.1"
kotlinx-date-time = "0.4.0"
accompanist = "0.28.0"
jsoup = "1.15.3"
Expand Down
2 changes: 1 addition & 1 deletion i18n/src/commonMain/resources/MR/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<string name="retry_button">Retry</string>
<string name="done_button">Okay</string>
<string name="wrong_link_report_title">The following feeds were not added because they are not valid</string>
<string name="feed_add_in_progress_message">Please wait, every feed availability is being checked</string>
<string name="new_release_available_title">A new version of FeedFlow is available:</string>
<string name="new_release_available_link">Download here</string>
<string name="feed_add_in_progress_message">Please wait, every feed availability is being checked. The operation can take a while depending on the amount of feeds that you are importing</string>
</resources>
34 changes: 17 additions & 17 deletions iosApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>firefox</string>
<string>ddgQuickLink</string>
<string>brave</string>
<string>googlechromes</string>
<string>firefox-focus</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand All @@ -18,6 +10,10 @@
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
</array>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
Expand All @@ -28,8 +24,21 @@
<string>VERSION_CODE</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>firefox</string>
<string>ddgQuickLink</string>
<string>brave</string>
<string>googlechromes</string>
<string>firefox-focus</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand All @@ -54,14 +63,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
28 changes: 13 additions & 15 deletions iosApp/Source/App/FeedFlowApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,26 @@ struct FeedFlowApp: App {
@StateObject var browserSelector: BrowserSelector = BrowserSelector()

init() {
#if !DEBUG
#if !DEBUG
CrashlyticsKt.setupCrashlytics()
#endif
#endif
startKoin()
}

var body: some Scene {
WindowGroup {
ContentView()
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(appState)
.environmentObject(browserSelector)
}
}
}
}
}

class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
#if !DEBUG
FirebaseApp.configure()
#endif

return true
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
#if !DEBUG
FirebaseApp.configure()
#endif
return true
}
}
2 changes: 2 additions & 0 deletions iosApp/Source/DI/Koin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ private var _koin: Koin_coreKoin?
var koin: Koin_coreKoin {
return _koin!
}

let localizer = MR.strings()
4 changes: 2 additions & 2 deletions iosApp/Source/Home/Components/EmptyFeedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ struct EmptyFeedView: View {

var body: some View {
VStack {
Text(MR.strings().empty_feed_message.localized)
Text(localizer.empty_feed_message.localized)
.font(.body)

Button(
MR.strings().refresh_feeds.localized,
localizer.refresh_feeds.localized,
action: {
onReloadClick()
}
Expand Down
50 changes: 36 additions & 14 deletions iosApp/Source/Home/Components/FeedListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ struct FeedListView: View {
onReloadClick: onReloadClick
)
} else if feedState.isEmpty {
ProgressView()
} else {
VStack(alignment: .center) {
LoadingHeader(
loadingState: loadingState,
showLoading: showLoading
)

if let feedCount = loadingState?.refreshedFeedCount, let totalFeedCount = loadingState?.totalFeedCount {

if showLoading {
Spacer()

let feedRefreshCounter = "\(feedCount)/\(totalFeedCount)"
ProgressView()

let loadingFeedString = LocalizationUtils.shared.formatString(
resource: MR.strings().loading_feed_message,
args: [feedRefreshCounter]
)
Text(loadingFeedString)
.font(.body)
}
}
Spacer()
}
} else {
VStack(alignment: .center) {
LoadingHeader(
loadingState: loadingState,
showLoading: showLoading
)

List {
ForEach(feedState, id: \.self.id) { feedItem in
Expand Down Expand Up @@ -82,7 +82,29 @@ struct FeedListView: View {
}
}
}
}

struct LoadingHeader: View {
var loadingState: FeedUpdateStatus?
var showLoading: Bool

var body: some View {
if let feedCount = loadingState?.refreshedFeedCount, let totalFeedCount = loadingState?.totalFeedCount {

if showLoading {

let feedRefreshCounter = "\(feedCount)/\(totalFeedCount)"

let loadingFeedString = LocalizationUtils.shared.formatString(
resource: MR.strings().loading_feed_message,
args: [feedRefreshCounter]
)
Text(loadingFeedString)
.font(.body)
}
}

}
}

struct FeedListView_Previews: PreviewProvider {
Expand Down
4 changes: 2 additions & 2 deletions iosApp/Source/Home/Components/NoFeedsSourceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ struct NoFeedsSourceView: View {

var body: some View {
VStack {
Text(MR.strings().no_feeds_found_message.localized)
Text(localizer.no_feeds_found_message.localized)
.font(.body)

Button(
MR.strings().add_feed.localized,
localizer.add_feed.localized,
action: {
onAddFeedClick()
}
Expand Down
22 changes: 11 additions & 11 deletions iosApp/Source/Home/HomeScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ struct HomeScreen: View {
private func emitGenericError() {
self.appState.snackbarQueue.append(
SnackbarData(
title: MR.strings().generic_error_message.localized,
title: localizer.generic_error_message.localized,
subtitle: nil,
showBanner: true
)
Expand Down Expand Up @@ -162,7 +162,7 @@ struct HomeContent: View {
)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Text("\(MR.strings().app_name.localized) (\(unreadCount))")
Text("\(localizer.app_name.localized) (\(unreadCount))")
.font(.title2)
.padding(.vertical, Spacing.medium)
.onTapGesture(count: 2) {
Expand All @@ -186,7 +186,7 @@ struct HomeContent: View {
},
label: {
Label(
MR.strings().mark_all_read_button.localized,
localizer.mark_all_read_button.localized,
systemImage: "checkmark"
)
}
Expand All @@ -198,7 +198,7 @@ struct HomeContent: View {
},
label: {
Label(
MR.strings().clear_old_articles_button.localized,
localizer.clear_old_articles_button.localized,
systemImage: "trash"
)
}
Expand All @@ -210,7 +210,7 @@ struct HomeContent: View {
},
label: {
Label(
MR.strings().force_feed_refresh.localized,
localizer.force_feed_refresh.localized,
systemImage: "arrow.clockwise"
)
}
Expand All @@ -222,7 +222,7 @@ struct HomeContent: View {
},
label: {
Label(
MR.strings().feeds_title.localized,
localizer.feeds_title.localized,
systemImage: "list.bullet.rectangle.portrait"
)
}
Expand All @@ -231,7 +231,7 @@ struct HomeContent: View {
Menu {
Picker(
selection: $browserSelector.selectedBrowser,
label: Text(MR.strings().browser_selection_button.localized)
label: Text(localizer.browser_selection_button.localized)
) {
ForEach(browserSelector.browsers, id: \.self) { period in
Text(period.name).tag(period as Browser?)
Expand All @@ -240,14 +240,14 @@ struct HomeContent: View {
}
label: {
Label(
MR.strings().browser_selection_button.localized,
localizer.browser_selection_button.localized,
systemImage: "globe"
)
}

NavigationLink(value: Route.importExportScreen) {
Label(
MR.strings().import_export_opml.localized,
localizer.import_export_opml.localized,
systemImage: "arrow.up.arrow.down"
)
}
Expand All @@ -260,7 +260,7 @@ struct HomeContent: View {
},
label: {
Label(
MR.strings().report_issue_button.localized,
localizer.report_issue_button.localized,
systemImage: "ladybug"
)
}
Expand All @@ -282,7 +282,7 @@ struct HomeContent: View {

NavigationLink(value: Route.aboutScreen) {
Label(
MR.strings().about_button.localized,
localizer.about_button.localized,
systemImage: "info.circle"
)
}
Expand Down
10 changes: 5 additions & 5 deletions iosApp/Source/Settings/About/AboutScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ struct AboutScreen: View {
var body: some View {

VStack {
Text(MR.strings().about_the_app.localized)
Text(localizer.about_the_app.localized)
.padding(Spacing.regular)
.font(.system(size: 16))

Button(
MR.strings().open_website_button.localized,
localizer.open_website_button.localized,
action: {
if let url = URL(string: Websites.shared.FEED_FLOW_WEBSITE) {
self.openURL(url)
Expand All @@ -35,7 +35,7 @@ struct AboutScreen: View {
.padding(.top, Spacing.regular)

Button(
MR.strings().open_source_licenses.localized,
localizer.open_source_licenses.localized,
action: {
let baseURL = Bundle.main.url(forResource: "licenses", withExtension: "html")!
let htmlString = try? String(contentsOf: baseURL, encoding: String.Encoding.utf8)
Expand All @@ -50,13 +50,13 @@ struct AboutScreen: View {
Spacer()

let authorLink: LocalizedStringKey = """
\(MR.strings().author_label.localized) [Marco Gomiero](https://www.marcogomiero.com)
\(localizer.author_label.localized) [Marco Gomiero](https://www.marcogomiero.com)
"""
Text(authorLink)
}.sheet(isPresented: $showLicensesSheet) {
LicensesScreen(htmlContent: licensesContent)
}
.navigationTitle(MR.strings().about_nav_bar.localized)
.navigationTitle(localizer.about_nav_bar.localized)
.navigationBarTitleDisplayMode(.inline)

}
Expand Down
2 changes: 1 addition & 1 deletion iosApp/Source/Settings/About/LicensesScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct LicensesScreen: View {
}

ToolbarItem(placement: .navigationBarLeading) {
Text(MR.strings().open_source_nav_bar.localized)
Text(localizer.open_source_nav_bar.localized)
.font(.title2)
.padding(.vertical, Spacing.medium)
}
Expand Down
Loading

0 comments on commit 9634325

Please sign in to comment.