Add %app% and %package% filename placeholders for foreground app info#703
Add %app% and %package% filename placeholders for foreground app info#703Self-Perfection wants to merge 12 commits intocvzi:mainfrom
Conversation
Allow users to include the foreground application name or package name in screenshot filenames. The accessibility service now tracks the foreground package unconditionally (not only when package filter is enabled), and formatFileName resolves the new placeholders via PackageManager.getApplicationLabel(). https://claude.ai/code/session_011TTQJFxqPwq3RD1tmtprvM
Allow users to include the foreground application name or package name in screenshot filenames. The accessibility service now tracks the foreground package unconditionally (not only when package filter is enabled), and formatFileName resolves the new placeholders via PackageManager.getApplicationLabel(). https://claude.ai/code/session_011TTQJFxqPwq3RD1tmtprvM
|
I ran the Github action on my repository, otherwise it won't run correctly. You can download the apk here at the bottom: https://github.com/cvzi/ScreenshotTile/actions/runs/21922996743 |
|
Dang. When called as digital assistant it always produces %app% = "Screenshot Tile" regardless of actual app that was screenshotted. |
When taking a screenshot via Digital Assistant, Quick Settings tile, or floating button, the app's own window briefly comes to foreground. This causes onAccessibilityEvent to overwrite lastPackageName with the app's own package name before formatFileName() reads it. Filter out the app's own package in onAccessibilityEvent so that lastPackageName retains the actual foreground app. https://claude.ai/code/session_011TTQJFxqPwq3RD1tmtprvM
When taking a screenshot via Digital Assistant, Quick Settings tile, or floating button, the app's own window briefly comes to foreground. This causes onAccessibilityEvent to overwrite lastPackageName with the app's own package name before formatFileName() reads it. Filter out the app's own package in onAccessibilityEvent so that lastPackageName retains the actual foreground app. https://claude.ai/code/session_011TTQJFxqPwq3RD1tmtprvM
|
OK I added proprosed fix for this case Trade-off: If the user takes a screenshot of ScreenshotTile itself (e.g. its settings screen), |
|
Github action is running here: https://github.com/cvzi/ScreenshotTile/actions/runs/21924410958 |
|
Well, it got better.
But somehow Probably in this case For my use case |
%app% requires QUERY_ALL_PACKAGES to reliably resolve human-readable app labels via PackageManager. Without it, Android 11+ package visibility restrictions cause getApplicationInfo() to fail for most packages. The code still supports %app% for users who add it manually, but it is no longer advertised in the UI. Added a comment explaining the limitation. https://claude.ai/code/session_011TTQJFxqPwq3RD1tmtprvM
|
There should already be a function to load the appname of packages in the app, because there is a setting where the user can select to hide the floating button on selected apps. I don't know if that function is different to this or not, I think it should be in this file if you want to ask AI: app/src/main/java/com/github/cvzi/screenshottile/utils/PackagesRecyclerViewAdapter.kt Anyway, I can take a closer look on the weekend. |
This reverts commit 22201e3.
* Add %app% and %package% filename placeholders for foreground app info Allow users to include the foreground application name or package name in screenshot filenames. The accessibility service now tracks the foreground package unconditionally (not only when package filter is enabled), and formatFileName resolves the new placeholders via PackageManager.getApplicationLabel(). https://claude.ai/code/session_011TTQJFxqPwq3RD1tmtprvM * Fix %app% and %package% always resolving to Screenshot Tile When taking a screenshot via Digital Assistant, Quick Settings tile, or floating button, the app's own window briefly comes to foreground. This causes onAccessibilityEvent to overwrite lastPackageName with the app's own package name before formatFileName() reads it. Filter out the app's own package in onAccessibilityEvent so that lastPackageName retains the actual foreground app. https://claude.ai/code/session_011TTQJFxqPwq3RD1tmtprvM * Remove %app% from filename placeholders documentation %app% requires QUERY_ALL_PACKAGES to reliably resolve human-readable app labels via PackageManager. Without it, Android 11+ package visibility restrictions cause getApplicationInfo() to fail for most packages. The code still supports %app% for users who add it manually, but it is no longer advertised in the UI. Added a comment explaining the limitation. https://claude.ai/code/session_011TTQJFxqPwq3RD1tmtprvM * Revert "Remove %app% from filename placeholders documentation" This reverts commit 22201e3. * still run function even if event.packageName == packageName * more robust label resolve for `%app%` --------- Co-authored-by: Claude <noreply@anthropic.com>
|
I have improved the |
Allow users to include the foreground application name or package name in screenshot filenames. The accessibility service now tracks the foreground package unconditionally (not only when package filter is enabled), and formatFileName resolves the new placeholders via PackageManager.getApplicationLabel().
https://claude.ai/code/session_011TTQJFxqPwq3RD1tmtprvM
Not yet tested. I hope GitHub workflow will run after PR and will generate APK that I will be able to test.