Skip to content

Commit

Permalink
fix(opml): bump opml-parser to 3.1.0 and re-design OPML export dialog (
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashinch authored Feb 20, 2024
1 parent 2438b27 commit 2d9e3de
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 23 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/me/ash/reader/ui/ext/DateExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import java.util.Locale
object DateFormat {
val YYYY_MM_DD_HH_MM_SS = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
val YYYY_MM_DD_DASH_HH_MM_SS = SimpleDateFormat("yyyy-MM-dd-HH:mm:ss")
val YYYY_MM_DD_DASH_HH_MM_SS_DASH = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss")
}

fun Date.toString(format: SimpleDateFormat): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@ import androidx.activity.compose.ManagedActivityResultLauncher
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.DeleteSweep
import androidx.compose.material.icons.outlined.PersonOff
import androidx.compose.material.icons.rounded.ArrowBack
import androidx.compose.material.icons.rounded.Close
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
Expand All @@ -28,9 +34,13 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.BaselineShift
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
Expand Down Expand Up @@ -415,37 +425,88 @@ fun AccountDetailsPage(
},
)

RadioDialog(
RYDialog(
visible = exportOPMLModeDialogVisible,
title = stringResource(R.string.export_as_opml),
description = stringResource(R.string.additional_info_desc),
options = listOf(
RadioDialogOption(
text = stringResource(R.string.include_additional_info),
selected = uiState.exportOPMLMode == ExportOPMLMode.ATTACH_INFO,
title = {
Text(
text = stringResource(R.string.export_as_opml),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.titleLarge,
)
},
text = {
LazyColumn {
item {
Text(text = stringResource(R.string.additional_info_desc))
Spacer(modifier = Modifier.height(16.dp))
}
items(listOf(
RadioDialogOption(
text = context.getString(R.string.include_additional_info),
selected = uiState.exportOPMLMode == ExportOPMLMode.ATTACH_INFO,
) {
viewModel.changeExportOPMLMode(ExportOPMLMode.ATTACH_INFO)
},
RadioDialogOption(
text = context.getString(R.string.exclude),
selected = uiState.exportOPMLMode == ExportOPMLMode.NO_ATTACH,
) {
viewModel.changeExportOPMLMode(ExportOPMLMode.NO_ATTACH)
}
)) { option ->
Row(
modifier = Modifier
.fillMaxWidth()
.clip(CircleShape)
.clickable {
option.onClick()
},
verticalAlignment = Alignment.CenterVertically,
) {
RadioButton(selected = option.selected, onClick = {
option.onClick()
})
Text(
modifier = Modifier.padding(start = 6.dp),
text = option.text,
style = MaterialTheme.typography.bodyLarge.copy(
baselineShift = BaselineShift.None
).merge(other = option.style),
color = MaterialTheme.colorScheme.onSurface,
)
}
}
}
},
confirmButton = {
TextButton(
onClick = {
exportOPMLModeDialogVisible = false
launcherOPMLFile(context, launcher)
}
) {
viewModel.changeExportOPMLMode(ExportOPMLMode.ATTACH_INFO)
launcherOPMLFile(context, launcher)
},
RadioDialogOption(
text = stringResource(R.string.exclude),
selected = uiState.exportOPMLMode == ExportOPMLMode.NO_ATTACH,
Text(stringResource(R.string.export))
}
},
dismissButton = {
TextButton(
onClick = { exportOPMLModeDialogVisible = false }
) {
viewModel.changeExportOPMLMode(ExportOPMLMode.NO_ATTACH)
launcherOPMLFile(context, launcher)
Text(stringResource(R.string.cancel))
}
)
) {
exportOPMLModeDialogVisible = false
}
},
onDismissRequest = {
exportOPMLModeDialogVisible = false
}
)
}

private fun launcherOPMLFile(
context: Context,
launcher: ManagedActivityResultLauncher<String, Uri?>,
) {
launcher.launch("" +
"${context.getString(R.string.read_you)}-" +
launcher.launch("Read-You-" +
"${context.getCurrentVersion()}-export-" +
"${Date().toString(DateFormat.YYYY_MM_DD_DASH_HH_MM_SS)}.opml")
"${Date().toString(DateFormat.YYYY_MM_DD_DASH_HH_MM_SS_DASH)}.opml")
}
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,5 @@
<string name="all_read">所有已读项</string>
<string name="read_excluding_starred">已读项,但已加星标的除外</string>
<string name="external_links">外部链接</string>
<string name="export">导出</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,5 @@
<string name="none">None</string>
<string name="toggle_read">Toggle read</string>
<string name="toggle_starred">Toggle starred</string>
<string name="export">Export</string>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ buildscript {
// https://github.com/dankito/Readability4J
readability4j = '1.0.8'
// https://github.com/mdewilde/opml-parser
opmlParser = '2.2.0'
opmlParser = '3.1.0'
// http://bigbadaboom.github.io/androidsvg/release_notes.html
androidSVG = '1.4'
}
Expand Down

0 comments on commit 2d9e3de

Please sign in to comment.