feat: Implement ActivityResultContract - #1033
Conversation
Motivation: - Provide state-of-the-art access to Nextcloud Single Sign On - Hide complete permission granting and account importing process behind a clear API surface - Deprecate methods that rely on deprecated Android framework methods like onActivityResult - Enhance maintainability and make refactoring easier in the future when the deprecated methods have eventually been removed or marked as private Refs: #448 Co-authored-by: Gemini Signed-off-by: Stefan Niedermann <info@niedermann.it>
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| CodeStyle | 1 minor |
🟢 Metrics 14 complexity
Metric Results Complexity 14
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Additional informationException HandlingA third party app can start the import process and gets either a This aligns with other ThemingThere are multiple sources of dialogs that may look different within the flow:
Given this does not affect the (now) deprecated way of importing accounts, this can be enhanced progressively in my opinion, so this should not be a show stopper. TestingTested successfully manually on AVD API level 24 without Google Play Services and API Level 36.1 with Google Play Services. |
@stefan-niedermann Likely depends on how they have been implemented. Lately we migrated various parts of the UI to Composables and with that we get theming "for free" in the sense that we now just to proper design tokens for styling and inject the apps server theme and are done, everything else properly managed by the Composables themselves now. SO no need for calling theme APIs any longer 🚀 |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
|
|
||
| if (savedInstanceState == null) { | ||
|
|
||
| try { |
There was a problem hiding this comment.
Why nested try block used here?
|
|
||
| /// This is a Trampoline Activity that takes care about requesting all necessary permissions and guiding the user through the complete import flow. | ||
| /// It is extremely important to catch *any* error and finish this activity because otherwise, the Trampoline Activity will stay on top but transparent, so users can't see it and users can't interact with their (visible) 3rd party app anymore. | ||
| public class ImportSsoAccountActivity extends AppCompatActivity { |
There was a problem hiding this comment.
Can't we use Kotlin for new files?
There was a problem hiding this comment.
Sure, one can do this. Please note, that (speaking for me personally only) enforcing Kotlin will stop further contributions from my side to this library. I don't want to trigger a "Kotlin vs. Java" discussion, this is a personal decision.
There was a problem hiding this comment.
Of course Java is perfectly fine; it was just a question for new file.
Thank you for the PR :)
| protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
|
|
||
| if (savedInstanceState == null) { |
There was a problem hiding this comment.
We can fail fast here instead nested if.
| * | ||
| * @see <a href="https://developer.android.com/training/basics/intents/result"><code>ActivityResultContract</code></a> | ||
| */ | ||
| public class ImportSsoAccount extends ActivityResultContract<Void, SingleSignOnAccount> { |
There was a problem hiding this comment.
Can't we use Kotlin for new files?
Refs: #448 Signed-off-by: Stefan Niedermann <info@niedermann.it>
Motivation:
Refs: #448
Co-authored-by: Gemini
🤖 AI (if applicable)