-
Notifications
You must be signed in to change notification settings - Fork 521
android: move taildrop directory selector out of onboarding #669
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
base: main
Are you sure you want to change the base?
Conversation
Pull Request Revisions
✅ AI review completed for r3 HelpReact with emojis to give feedback on AI-generated reviews:
We'd love to hear from you—reach out anytime at [email protected]. |
android/src/main/java/com/tailscale/ipn/util/ShareFileHelper.kt
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
viewModel.setDirectoryPickerLauncher(directoryPickerLauncher) | ||
appViewModel.setDirectoryPickerLauncher(directoryPickerLauncher) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the MainActivity.kt (lines 221-224), you've moved the directory picker launcher assignment from viewModel to appViewModel, but I don't see corresponding changes in the AppViewModel class to handle this functionality. Make sure the method exists in the new class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generateNewFilename method in ShareFileHelper.kt currently uses UUID for generating unique filenames. Would using a more user-friendly approach like adding a simple incrementing number (e.g., 'file(1).txt') provide a better user experience for duplicate files?
da2e5c3
to
d68b2b6
Compare
@@ -372,7 +372,7 @@ func (a *App) watchFileOpsChanges() { | |||
a.directFileRoot = newPath | |||
a.backendRestartCh <- struct{}{} | |||
case helper := <-onShareFileHelper: | |||
log.Printf("Got shareFIleHelper") | |||
log.Printf("Got shareFileHelper") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In backend.go, there's a simple typo fix from 'shareFIleHelper' to 'shareFileHelper' which is good. Consider adding a simple comment before this log statement to describe the purpose of this branch in the select statement for better code maintainability.
android/src/main/java/com/tailscale/ipn/util/ShareFileHelper.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In MainView.kt, the WindowInsets access has been changed from WindowInsets.statusBars
to WindowInsets.Companion.statusBars
. This appears to be a regression as the Companion access is typically needed for older Kotlin versions, whereas direct property access is the modern approach. Unless there's a specific compatibility issue, consider reverting to the direct property access.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a rebase and a quick check against the lastest main. I think I probably broke this with some of the temporary 1.84 patches.
136d472
to
620ad22
Compare
-ShareFileHelper manages directory readiness; when a file is being shared to the device, it emits a signal to prompt the user to pick a directory -Remove MDM auth key check; there is no longer any need to make assumptions about Taildrop usage, and we only show the directory selector when they are receiving a Taildropped file -Listen for Taildrop receipt in application view model (formerly VpnViewModel, now renamed due to its expanded scope), since Taildrop can occur even without MainActivity, and move dir picker out of MainView -Switch from StateFlow to SharedFlow since this is an event that only needs to be handled once rather than a persistent UI state. -ShareFileHelper keeps track of Taildrop dir rather than the Taildrop extension managerOptions; this allows the correct directory to be used without having to send a new request or restart LocalBackend -Don't restart LocalBackend on Taildrop dir selection because this is no longer necessary Follow-up: implement resume Taildrop in SAF Updates tailscale/corp#29211 Signed-off-by: kari-ts <[email protected]>
@@ -337,8 +320,12 @@ func (a *App) newBackend(dataDir string, appCtx AppContext, store *stateStore, | |||
} | |||
lb, err := ipnlocal.NewLocalBackend(logf, logID.Public(), sys, 0) | |||
if ext, ok := ipnlocal.GetExt[*taildrop.Extension](lb); ok { | |||
defer func() { | |||
if r := recover(); r != nil { | |||
log.Printf("panic in taildrop extension init: %v", r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this? How do we know that the panic is in taildrop extension init?
} | ||
} | ||
} | ||
|
||
func (a *App) WaitForTaildropReady() { | ||
<-a.taildropReady |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The channel is never signaled, so WaitForTaildropReady
will never return. But it also looks like it's never called?
@@ -125,6 +125,8 @@ type Application interface { | |||
// on every new ipn.Notify message. The returned NotificationManager | |||
// allows the watcher to stop watching notifications. | |||
WatchNotifications(mask int, cb NotificationCallback) NotificationManager | |||
|
|||
WaitForTaildropReady() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please either remove it from the interface and implementation, or add a docstring if you plan to fully implement it in this PR?
context.contentResolver.openInputStream(partialUriObj)?.use { input -> | ||
context.contentResolver.openOutputStream(destFile.uri)?.use { output -> | ||
input.copyTo(output) | ||
} ?: throw IOException("Unable to open output stream for URI: ${destFile.uri}") | ||
} ?: throw IOException("Unable to open input stream for URI: $partialUri") | ||
} ?: throw IOException("Unable to open output stream for URI: $finalTargetName") | ||
} ?: throw IOException("Unable to open input stream for URI $partialUri") | ||
|
||
DocumentFile.fromSingleUri(context, partialUriObj)?.delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use DocumentFile.renameTo instead of copying the content and deleting the source file?
android: move taildrop directory selector out of onboarding
-ShareFileHelper manages directory readiness; when a file is being shared to the device, it emits a signal to prompt the user to pick a directory
-Remove MDM auth key check; there is no longer any need to make assumptions about Taildrop usage, and we only show the directory selector when they are receiving a Taildropped file
-Listen for Taildrop receipt in application view model (formerly VpnViewModel, now renamed due to its expanded scope), since Taildrop can occur even without MainActivity, and move dir picker out of MainView
-Switch from StateFlow to SharedFlow since this is an event that only needs to be handled once rather than a persistent UI state.
-ShareFileHelper keeps track of Taildrop dir rather than the Taildrop extension managerOptions; this allows the correct directory to be used without having to send a new request or restart LocalBackend
-Don't restart LocalBackend on Taildrop dir selection because this is no longer necessary
Follow-up: implement resume Taildrop in SAF
Updates tailscale/corp#29211
Updates tailscale/corp#29211