Skip to content
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

#13282: Fixes Android Studio Warnings under Kotlin Header #15704

Closed
wants to merge 15 commits into from
Closed

#13282: Fixes Android Studio Warnings under Kotlin Header #15704

wants to merge 15 commits into from

Conversation

awanishyadav967
Copy link
Contributor

Description

I addressed the issue #13282 by fixing Android Studio warnings under Kotlin ->redundant constructs header (The list of warnings can be obtained via: Code -> Inspect Code). The changes include removing redundant constructs such as unused imports and redundant quantifier names.

Fixes

Approach

I reviewed the code and identified areas with Android Studio warnings. I removed unnecessary constructs to improve code readability and maintainability.

How Has This Been Tested?

I tested these changes on Level 30 (Android 11).

Before

Screenshot1

After

Screenshot2

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Copy link

welcome bot commented Feb 28, 2024

First PR! 🚀 We sincerely appreciate that you have taken the time to propose a change to AnkiDroid! Please have patience with us as we are all volunteers - we will get to this as soon as possible.

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

Thanks!

AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt Outdated Show resolved Hide resolved
public object FlashCardsContract {
public const val AUTHORITY: String = BuildConfig.AUTHORITY
public const val READ_WRITE_PERMISSION: String = BuildConfig.READ_WRITE_PERMISSION
object FlashCardsContract {
Copy link
Member

@david-allison david-allison Feb 28, 2024

Choose a reason for hiding this comment

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

all our API files should require public due to explicitApi

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Feb 28, 2024
object FlashCardsContract {
const val AUTHORITY: String = BuildConfig.AUTHORITY
const val READ_WRITE_PERMISSION: String = BuildConfig.READ_WRITE_PERMISSION
public object FlashCardsContract {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

all the files in api should be reverted

@awanishyadav967
Copy link
Contributor Author

Thanks!

Thank you for your feedback and suggestions. I've made the necessary changes as requested. Please take another look when you have a chance.

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

Thanks! Last one I think

@@ -339,7 +346,7 @@ open class AnkiActivity : AppCompatActivity, SimpleMessageDialogListener {
.setToolbarColor(toolbarColor)
.setNavigationBarColor(navBarColor)
.build()
val builder = CustomTabsIntent.Builder(customTabActivityHelper.session)
val builder = Builder(customTabActivityHelper.session)
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be imported as we lose context for the containing type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you recommend reverting the change or is there a preferred approach for handling this? @david-allison

Copy link
Member

Choose a reason for hiding this comment

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

revert the change, remove the import if possible

@@ -189,7 +189,7 @@ public object FlashCardsContract {
* --------------------------------------------------------------------------------------------------------------------
* ```
*/
public object Note {
object Note {
Copy link
Member

Choose a reason for hiding this comment

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

changes to this class need reverting

@@ -24,7 +24,7 @@ import java.util.*
* Representation of the contents of a note in AnkiDroid.
*/
@Suppress("unused")
public class NoteInfo {
class NoteInfo {
Copy link
Member

Choose a reason for hiding this comment

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

changes to this class need reverting

@david-allison david-allison added squash-merge The pull request currently requires maintainers to "Squash Merge" and removed Needs Author Reply Waiting for a reply from the original author labels Feb 28, 2024
@neeldoshii
Copy link
Contributor

Code Quality failing.

try running
./gradlew ktlintFormat to fix the code qualty test.

@lukstbit lukstbit added the Needs Author Reply Waiting for a reply from the original author label Feb 29, 2024
@awanishyadav967
Copy link
Contributor Author

Code Quality failing.

try running ./gradlew ktlintFormat to fix the code qualty test.

Hi @neeldoshii thanks ,I think this happen because I commit (try to solve merge conflict in one of the import) directly from the github , Right now i am travelling ,there is few review(comments) i have to revert ,I will soon make a new PR 👍

@david-allison
Copy link
Member

Hi @awanishyadav967, we prefer rebase + force-push rather than making new PRs, we want to keep the code review history in one place

No rush, and enjoy your travels!

@awanishyadav967
Copy link
Contributor Author

Hi @awanishyadav967, we prefer rebase + force-push rather than making new PRs, we want to keep the code review history in one place

No rush, and enjoy your travels!

Thanks, @david-allison, for the input! I'll use rebase + force-push to maintain the code review history in one place. Appreciate the guidance, and I'll take care of it.

@neeldoshii
Copy link
Contributor

Test cases failing.

Visibility must be specified in explicit API mode

@david-allison
Copy link
Member

Just to note: you can reproduce the local failures by rebasing onto main

BrayanDSO and others added 10 commits February 29, 2024 22:42
the fields need to be passed for the card to be previewed, but they weren't built in IO so they couldn't have their values taken
* Keep the widgets disabled until the application has storage access
If a screen is backgrounded, `requireActivity()` throws
`IllegalStateException("Fragment " + this + " not attached to an activity.")`

The request which caused this was `/_anki/congratsInfo` which occurred every minute

This was returned to the screen and caused a messagebox to appear

And one messagebox per minute eventually exceeded the system window limit

Causing issue 15659: a crash with "window count is over max!!"

To fix this, allow a null activity

Fixes 15679
The current implementation using messages and handlers for async dialogs
means that if the user tries to import before actually starting the app
the import dialog ends up being shown in the introduction screen ending
up in a crash. These changes prevent that by checking for this scenario
and notifying the user that he must start the app at least once before
any import can be done.

The hasShownAppIntro() was moved to better structure the code(it's related
to the introduction screen) and for ease of access in the screens that use it.
neeldoshii and others added 3 commits March 1, 2024 01:22
* Fix : Multiple instance of dialog shown
* Simplified the layout, increased padding and touch target
* Increased the top and bottom padding
* Fix : My search uses divider and fixed padding
@awanishyadav967
Copy link
Contributor Author

Test cases failing.

Visibility must be specified in explicit API mode

Hi @neeldoshii ,The local test cases passed, but they're failing in CI. Any suggestions or insights into possible reasons for the this?

@neeldoshii
Copy link
Contributor

Hi @neeldoshii ,The local test cases passed, but they're failing in CI. Any suggestions or insights into possible reasons for the this?

Hi @awanishyadav967, you haven't done rebase properly see
image

Coming to your point, #15709 we have added an explictAPi() method which make sure's all the API calls are set to public.
Check Comment By @david-allison

Also you have conflicts in your PR now so you need to fix the conflicts too 😔.

@awanishyadav967 awanishyadav967 closed this by deleting the head repository Mar 8, 2024
@neeldoshii
Copy link
Contributor

Hi @awanishyadav967, I noticed you closed the PR do you need any help?

@awanishyadav967
Copy link
Contributor Author

Hi @awanishyadav967, I noticed you closed the PR do you need any help?

Hi @neeldoshii I think I created a mess here, I just want to create new pr ,I tried rebasing and reverting my changes but it does worked for me .

@awanishyadav967
Copy link
Contributor Author

Hi @david-allison @neeldoshii,
Just wanted to give you a heads up – I've set up a new PR and linked it here. Take a look whenever you get a chance, and let me know if any changes are needed. Appreciate your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has Conflicts Needs Author Reply Waiting for a reply from the original author New contributor squash-merge The pull request currently requires maintainers to "Squash Merge"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Cleanup]: Fix Android Studio Warnings
7 participants