Skip to content

Commit

Permalink
Add bug report
Browse files Browse the repository at this point in the history
  • Loading branch information
prof18 committed Jul 23, 2023
1 parent 047f4e6 commit 0f4a753
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.prof18.feedflow.settings.components.BrowserSelectionDialog
import com.prof18.feedflow.settings.components.SettingsDivider
import com.prof18.feedflow.settings.components.SettingsMenuItem
import com.prof18.feedflow.ui.preview.FeedFlowPreview
import com.prof18.feedflow.utils.UserFeedbackReporter
import dev.icerock.moko.resources.compose.stringResource
import org.koin.androidx.compose.koinViewModel
import org.koin.compose.koinInject
Expand Down Expand Up @@ -101,6 +102,12 @@ fun SettingsScreen(
},
navigateBack = navigateBack,
onAboutClick = onAboutClick,
onBugReportClick = {
browserManager.openUrl(
url = UserFeedbackReporter.getFeedbackUrl(),
context = context,
)
},
)
}

Expand All @@ -114,6 +121,7 @@ private fun SettingsScreenContent(
onBrowserSelected: (Browser) -> Unit,
navigateBack: () -> Unit,
onAboutClick: () -> Unit,
onBugReportClick: () -> Unit,
) {
val openFileAction = rememberLauncherForActivityResult(
ActivityResultContracts.OpenDocument(),
Expand Down Expand Up @@ -162,6 +170,7 @@ private fun SettingsScreenContent(
openFileAction = openFileAction,
createFileAction = createFileAction,
onAboutClick = onAboutClick,
onBugReportClick = onBugReportClick,
)
}
}
Expand Down Expand Up @@ -190,6 +199,7 @@ private fun SettingsNavBar(navigateBack: () -> Unit) {
)
}

@Suppress("LongMethod")
@Composable
private fun SettingsList(
modifier: Modifier = Modifier,
Expand All @@ -198,6 +208,7 @@ private fun SettingsList(
openFileAction: ManagedActivityResultLauncher<Array<String>, Uri?>,
createFileAction: ManagedActivityResultLauncher<String, Uri?>,
onAboutClick: () -> Unit,
onBugReportClick: () -> Unit,
) {
LazyColumn(
modifier = modifier,
Expand Down Expand Up @@ -252,6 +263,20 @@ private fun SettingsList(
SettingsDivider()
}

item {
SettingsMenuItem(
text = stringResource(
resource = MR.strings.report_issue_button,
),
) {
onBugReportClick()
}
}

item {
SettingsDivider()
}

item {
SettingsMenuItem(
text = stringResource(
Expand Down Expand Up @@ -289,6 +314,7 @@ private fun SettingsScreenPreview() {
onBrowserSelected = {},
navigateBack = {},
onAboutClick = {},
onBugReportClick = {},
)
}
}
4 changes: 4 additions & 0 deletions desktopApp/src/jvmMain/kotlin/com/prof18/feedflow/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import com.prof18.feedflow.presentation.SettingsViewModel
import com.prof18.feedflow.ui.style.FeedFlowTheme
import com.prof18.feedflow.ui.style.rememberDesktopDarkTheme
import com.prof18.feedflow.utils.AppEnvironment
import com.prof18.feedflow.utils.UserFeedbackReporter
import com.prof18.feedflow.utils.initSentry
import dev.icerock.moko.resources.compose.stringResource
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -182,6 +183,9 @@ fun main() = application {
onAboutClick = {
aboutDialogState = true
},
onBugReportClick = {
openInBrowser(UserFeedbackReporter.getFeedbackUrl())
},
)

MainContent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fun FrameWindowScope.FeedFlowMenuBar(
onFeedsListClick: () -> Unit,
onClearOldFeedClick: () -> Unit,
onAboutClick: () -> Unit,
onBugReportClick: () -> Unit,
) {
MenuBar {
Menu("File", mnemonic = 'F') {
Expand Down Expand Up @@ -69,6 +70,13 @@ fun FrameWindowScope.FeedFlowMenuBar(

Separator()

Item(
text = stringResource(resource = MR.strings.report_issue_button),
onClick = onBugReportClick,
)

Separator()

Item(
text = stringResource(resource = MR.strings.about_button),
onClick = onAboutClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down
16 changes: 16 additions & 0 deletions iosApp/Source/Home/HomeScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ struct HomeContent: View {
@EnvironmentObject var browserSelector: BrowserSelector
@EnvironmentObject var appState: AppState

@Environment(\.openURL) var openURL

@Binding var loadingState: FeedUpdateStatus?
@Binding var feedState: [FeedItem]
@Binding var showLoading: Bool
Expand Down Expand Up @@ -324,6 +326,20 @@ struct HomeContent: View {
}
)

Button(
action: {
if let url = URL(string: UserFeedbackReporter.shared.getFeedbackUrl()) {
self.openURL(url)
}
},
label: {
Label(
MR.strings().report_issue_button.localized,
systemImage: "ladybug"
)
}
)

NavigationLink(value: Route.aboutScreen) {
Label(
MR.strings().about_button.localized,
Expand Down
3 changes: 2 additions & 1 deletion iosApp/Source/Utils/IosHtmlParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class IosHtmlParser: HtmlParser {
let doc: Document = try SwiftSoup.parse(html)
return try doc.text()
} catch {
KotlinDependencies.shared.getLogger(tag: "IosHtmlParser").e(messageString: "Error during html parsing: \(error)")
KotlinDependencies.shared.getLogger(tag: "IosHtmlParser")
.e(messageString: "Error during html parsing: \(error)")
return nil
}
}
Expand Down
2 changes: 2 additions & 0 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ kotlin {
implementation(libs.kotlinx.coroutines.core)
implementation(libs.com.prof18.rss.parser)
implementation(libs.multiplatform.settings)
implementation(libs.kotlin.test)
implementation(libs.kotlin.test.junit)

api(libs.touchlab.kermit)
api(libs.moko.resources)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.util.*
import java.util.Locale

internal actual fun getDateMillisFromString(dateString: String, logger: Logger): Long? {
internal actual fun getDateMillisFromString(dateString: String, logger: Logger?): Long? {
val dateFormat = SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.getDefault())
return try {
dateFormat.parse(dateString)?.time
} catch (e: ParseException) {
logger.e(e) { "Error while trying to format the date with dateFormatter. Date: $dateString" }
logger?.e(e) {
"Error while trying to format the date with dateFormatter. Date: $dateString"
}
null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package com.prof18.feedflow.domain

import co.touchlab.kermit.Logger

internal expect fun getDateMillisFromString(dateString: String, logger: Logger): Long?
internal expect fun getDateMillisFromString(
dateString: String,
logger: Logger? = null,
): Long?

internal expect fun formatDate(millis: Long): String

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.prof18.feedflow.utils

object UserFeedbackReporter {
private const val baseUrl = "https://github.com/prof18/feed-flow/issues/new"
private const val title = "App issue"
private const val body = "Please describe the issue and provide a link to the RSS Feed that causes the issues:\n"

fun getFeedbackUrl(): String {
val encodedTitle = title.replace(" ", "+")
val encodedContent = body
.replace(" ", "+")
.replace("\n", "%0A")
return "$baseUrl?title=$encodedTitle&body=$encodedContent"
}
}
1 change: 1 addition & 0 deletions shared/src/commonMain/resources/MR/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@
<string name="about_the_app">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</string>
<string name="about_nav_bar">About</string>
<string name="open_source_nav_bar">Open source licenses</string>
<string name="report_issue_button">Report issue</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.prof18.feedflow.logging

import co.touchlab.kermit.ExperimentalKermitApi
import co.touchlab.kermit.LogWriter
import co.touchlab.kermit.crashlytics.CrashlyticsLogWriter

@OptIn(ExperimentalKermitApi::class)
actual fun crashReportingLogWriter(): LogWriter = CrashlyticsLogWriter()
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SentryLogWriter(
) : LogWriter() {

init {
@Suppress("UseRequire")
if (minCrashSeverity != null && minSeverity > minCrashSeverity) {
throw IllegalArgumentException(
"minSeverity ($minSeverity) cannot be greater than minCrashSeverity ($minCrashSeverity)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import platform.Foundation.dateWithTimeIntervalSince1970
import platform.Foundation.timeIntervalSince1970

@Suppress("TooGenericExceptionCaught")
internal actual fun getDateMillisFromString(dateString: String, logger: Logger): Long? {
internal actual fun getDateMillisFromString(dateString: String, logger: Logger?): Long? {
val dateFormatter = NSDateFormatter().apply {
setDateFormat("E, d MMM yyyy HH:mm:ss Z")
setLocale(NSLocale("en_US_POSIX"))
Expand Down Expand Up @@ -45,7 +45,7 @@ internal actual fun getDateMillisFromString(dateString: String, logger: Logger):

if (date == null) {
if (exception != null && message != null) {
logger.e(exception) {
logger?.e(exception) {
message
}
}
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion website/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ theme = "apsho"
weight = 2
[[menu.sitemap]]
name = "Privacy & Policy"
url = "/privacy"
url = "https://www.prof18.com/feed-flow/pp/privacy-policy-jul23/"
weight = 3
[[menu.sitemap]]
name = "Report issue"
Expand Down

0 comments on commit 0f4a753

Please sign in to comment.