Skip to content

added Tor disabled warning popup with informational dialog #675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

Elelan
Copy link

@Elelan Elelan commented Jun 3, 2025

No description provided.

@Elelan Elelan requested review from Copilot and prathieshna June 3, 2025 19:38
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces an informational dialog for the Tor toggle (disabled while the feature is under development), updates the supporting strings, adjusts the proof mode initialization logic by removing an Android version check, and adds a preview for the new dialog.

  • Added string resources for the Tor warning dialog
  • Enabled the Tor switch in settings to show an info dialog and prevent actual toggling
  • Removed the legacy Android <M API check in ProofModeHelper.init, potentially altering init behavior on older devices
  • Updated BaseDialog with an Info icon import, centered title alignment, and a Tor warning preview

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
app/src/main/res/values/strings.xml Added tor_disabled_title and tor_disabled_message entries
app/src/main/java/net/opendasharchive/openarchive/util/ProofModeHelper.kt Removed pre-M API level check and its fallback path
app/src/main/java/net/opendasharchive/openarchive/features/settings/SettingsFragment.kt Enabled Tor toggle to fire an informational dialog
app/src/main/java/net/opendasharchive/openarchive/features/core/dialog/BaseDialog.kt Imported Icons.Default.Info, centered BaseDialogTitle, and added preview
Comments suppressed due to low confidence (2)

app/src/main/java/net/opendasharchive/openarchive/util/ProofModeHelper.kt:21

  • Removal of the Build.VERSION.SDK_INT check drops the fallback path for pre-M devices, causing finishInit not to be called on older Android versions. Reintroduce a conditional or restructure the logic so that finishInit always runs when initialization is required.
val encryptedPassphrase = Prefs.proofModeEncryptedPassphrase

app/src/main/java/net/opendasharchive/openarchive/features/settings/SettingsFragment.kt:144

  • The new informational dialog flow for the Tor preference lacks unit or UI tests to verify it shows correctly and blocks toggling as intended. Consider adding preference interaction tests or a Compose preview assertion to cover this behavior.
setOnPreferenceClickListener {

Comment on lines +156 to +158
setOnPreferenceChangeListener { _, newValue ->
false
}
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Combining both click and change listeners to disable state changes can be simplified. You could disable the preference entirely or handle the blocking logic solely in the click listener for clearer intent.

Suggested change
setOnPreferenceChangeListener { _, newValue ->
false
}
// Removed redundant setOnPreferenceChangeListener

Copilot uses AI. Check for mistakes.

onClick = {
btn.action()
onDismiss()
})

Check warning

Code scanning / detekt

Reports missing newlines (e.g. between parentheses of a multi-line function call Warning

Missing newline before ")"
onClick = {
btn.action()
onDismiss()
})

Check warning

Code scanning / detekt

Reports incorrect argument list wrapping Warning

Missing newline before ")"
onClick = {
btn.action()
onDismiss()
})

Check warning

Code scanning / detekt

Reports missing newlines (e.g. between parentheses of a multi-line function call Warning

Missing newline before ")"
onClick = {
btn.action()
onDismiss()
})

Check warning

Code scanning / detekt

Reports incorrect argument list wrapping Warning

Missing newline before ")"
@Preview
@Preview(uiMode = UI_MODE_NIGHT_YES)
@Composable
private fun TorWarningDialogPreview() {

Check warning

Code scanning / detekt

Function names should follow the naming convention set in the configuration. Warning

Function names should match the pattern: [a-z][a-zA-Z0-9]*
@Preview
@Preview(uiMode = UI_MODE_NIGHT_YES)
@Composable
private fun TorWarningDialogPreview() {

Check warning

Code scanning / detekt

Private function is unused and should be removed. Warning

Private function TorWarningDialogPreview is unused.
Comment on lines +321 to +322

BaseDialog(

Check warning

Code scanning / detekt

Reports methods that have an empty first line. Warning

First line in a method block should not be empty
if (e is UserNotAuthenticatedException) {
Runtime.getRuntime().exit(0)
}
else {

Check warning

Code scanning / detekt

Reports spaces around keywords Warning

Unexpected newline before "else"
@Elelan Elelan merged commit 1a2c0c7 into next Jun 3, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant