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

Deprecation - convert to Preference fragments to avoid old API #5019

Closed
mikehardy opened this issue Oct 6, 2018 · 13 comments
Closed

Deprecation - convert to Preference fragments to avoid old API #5019

mikehardy opened this issue Oct 6, 2018 · 13 comments
Labels
Deprecation Warnings on deprecated API usage Help Wanted Requesting Pull Requests from volunteers Keep Open avoids the stale bot Priority-Low

Comments

@mikehardy
Copy link
Member

De-linting the codebase and this looks involved - we're using APIs that say this on the warning:

This function is not relevant for a modern fragment-based PreferenceActivity.

And the recommendation is to change how preferences are displayed completely, to fragments.

@timrae
Copy link
Member

timrae commented Oct 6, 2018

We already use preference fragments in the main preferences, or are you talking about deck options? If so, good luck with that rats nest lol.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 3, 2020

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

@github-actions github-actions bot added the Stale label Jun 3, 2020
@david-allison david-allison added Help Wanted Requesting Pull Requests from volunteers Deprecation Warnings on deprecated API usage Keep Open avoids the stale bot and removed Stale labels Jun 3, 2020
@mikehardy
Copy link
Member Author

This now affects the ability to move to API29 as a target as there is a fresh batch of deprecation prompting a move to https://developer.android.com/jetpack/androidx/releases/preference - #6365

mikehardy added a commit to mikehardy/Anki-Android that referenced this issue Sep 2, 2020
This allows compileSdk 29 to be used successfully
mikehardy added a commit to mikehardy/Anki-Android that referenced this issue Sep 5, 2020
This allows compileSdk 29 to be used successfully
mikehardy added a commit to mikehardy/Anki-Android that referenced this issue Sep 15, 2020
This allows compileSdk 29 to be used successfully
david-allison added a commit to david-allison/Anki-Android that referenced this issue Oct 2, 2020
This allows compileSdk 29 to be used successfully

� Conflicts:
�	AnkiDroid/src/main/java/com/ichi2/anki/Preferences.java
�	AnkiDroid/src/main/java/com/ichi2/preferences/CustomDialogPreference.java
david-allison added a commit to david-allison/Anki-Android that referenced this issue Oct 2, 2020
This allows compileSdk 29 to be used successfully
mikehardy added a commit that referenced this issue Oct 2, 2020
* Bump annotations from 20.0.0 to 20.1.0

Bumps [annotations](https://github.com/JetBrains/java-annotations) from 20.0.0 to 20.1.0.
- [Release notes](https://github.com/JetBrains/java-annotations/releases)
- [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md)
- [Commits](JetBrains/java-annotations@20.0.0...20.1.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* Bump mockito-inline from 3.5.7 to 3.5.9

Bumps [mockito-inline](https://github.com/mockito/mockito) from 3.5.7 to 3.5.9.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](mockito/mockito@v3.5.7...v3.5.9)

Signed-off-by: dependabot-preview[bot] <[email protected]>

* Bump other reference to annotations library

* Mark android.preference API usage for deprecation - #5019

This allows compileSdk 29 to be used successfully

* Use new Bitmap constant to avoid deprected old one

* Mark external storage directory API usage as deprecated #5304

* Mark MediaColumns DATA column usage as deprecated #7014

* Mark NetworkInfo usage as deprecated #7013

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Mike Hardy <[email protected]>
@MarioRomanDono
Copy link

Hey, I'm taking a look at this. I'm not sure if I'm missing something, but, in order to move to the new API, should I just change the import to androidx.preference and remove the old API uses in every affected file? I saw in the gradle.properties file that android.useAndroidX and android.enableJetifier flags are already set to true, which is a requisite pointed here.

@mikehardy
Copy link
Member Author

@MarioRomanDono more or less correct yes? The problem is that I think one or more of the preferences might not be converted to fragments which may imply a structural change

Either way it's a wide-ranging change, that's for sure, I just checked to see how many files were affected:

mike@isabela:~/work/AnkiDroid/Anki-Android-Upstream/AnkiDroid/src/main/java (master) % grep -r 5019 
com/ichi2/ui/AppCompatPreferenceActivity.java:@SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/ui/AutoSizeCheckBoxPreference.java:@SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/ui/ConfirmationPreference.java:@SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/ui/SeekBarPreference.java:@SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/anki/AnkiDroidApp.java:    @SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/anki/FilteredDeckOptions.java:    @SuppressWarnings("deprecation") // Tracked as #5019 on github
com/ichi2/anki/FilteredDeckOptions.java:    @SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/anki/FilteredDeckOptions.java:    @SuppressWarnings("deprecation") // conversion to fragments tracked in github as #5019
com/ichi2/anki/FilteredDeckOptions.java:    @SuppressWarnings("deprecation") // Tracked as #5019 on github
com/ichi2/anki/Preferences.java:@SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/anki/Preferences.java:@SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/anki/Preferences.java:    @SuppressWarnings("deprecation") // Tracked as #5019 on github - convert to fragments
com/ichi2/anki/Preferences.java:    @SuppressWarnings("deprecation") // Tracked as #5019 on github
com/ichi2/anki/DeckOptions.java:    @SuppressWarnings("deprecation") // conversion to fragments tracked as #5019 in github
com/ichi2/anki/DeckOptions.java:    @SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/anki/DeckOptions.java:    @SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/anki/DeckOptions.java:    @SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/anki/DeckOptions.java:    @SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/anki/DeckOptions.java:    @SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/preferences/StepsPreference.java:@SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/preferences/TimePreference.java:@SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/preferences/NumberRangePreference.java:@SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/preferences/IncrementerNumberRangePreference.java:@SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
com/ichi2/preferences/CustomDialogPreference.java:@SuppressWarnings("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019

!

@david-allison
Copy link
Member

david-allison commented Mar 27, 2021

This isn't going to be a good first issue due to the magnitude of the change required. Some initial research into the changes which will be made would be useful

@david-allison
Copy link
Member

The custom preferences require a lot more code to get working: https://stackoverflow.com/a/34398747/13121290

@david-allison david-allison self-assigned this Aug 11, 2021
@david-allison
Copy link
Member

I'm going to see this through for Preferences.java, which will take a large dent out of the work required for DeckOptions.java

@BrayanDSO
Copy link
Member

For anyone's information, DeckOptions will be replaced entirely by the new HTML page (#12175) when the new backend is the default. So there is only FilteredDeckOptions to fix (which gives me a headache just by looking at it)

@dae
Copy link
Contributor

dae commented Aug 31, 2023

@BrayanDSO is this ok to close?

edit: nevermind, I see FilteredDeckOptions still needs attention

@BrayanDSO
Copy link
Member

Honestly, I think that it's easier to migrate the desktop filtered Deck options screen to Svelte than migrating our screen to AndroidX prefs. That would benefit AnkiMobile as well, since I haven't found how to create a filtered decks there

@dae
Copy link
Contributor

dae commented Aug 31, 2023

AnkiMobile does have a screen (Filter/Cram option in cog menu), but would welcome this being ported to Svelte.

@BrayanDSO
Copy link
Member

Closing this as duplicate of #3625

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecation Warnings on deprecated API usage Help Wanted Requesting Pull Requests from volunteers Keep Open avoids the stale bot Priority-Low
Projects
None yet
Development

No branches or pull requests

6 participants