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

Add: Remove button for deck picker background image #16091

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

oyeraghib
Copy link
Contributor

Purpose / Description

Add: Remove button for deck picker background image

Fixes

Approach

Created a custom preference for adding the option to remove the image along with selecting the image.

Before

WhatsApp.Video.2024-04-04.at.11.53.17.AM.mp4

After

WhatsApp.Video.2024-04-04.at.11.53.25.AM.mp4

How Has This Been Tested?

Tested on:
Physical device - Pixel 6A (Android 13)
Emulator - Pixel 3a (Android 14)

Checklist

Please, go through these checks before submitting the PR.

  • 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

This class helps to bind the layout for deck picker background
Implement the interface and the functions to handle image select and image remove functionalities
@SanjaySargam
Copy link
Contributor

I'd suggest best and simple way:
Change text if image is selected -> Remove image else -> Select image

@oyeraghib
Copy link
Contributor Author

@SanjaySargam I think the problem with this approach would be replacing the image. If there is already a bg image and user decides to change to new image, first they have to remove the prior image and then they would get the option to "Select image", which I think is an extra unnecessary step from user's pov.

<PreferenceCategory android:title="@string/background_image_title" >
<Preference
<PreferenceCategory android:title="@string/background_image_title"
app:allowDividerBelow="false">
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you set this to false? Is there any specific reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After adding a custom layout for preferences, there was a divider below the title, and setting this to false removes that divider. So there is only one divider after that preference category.

fun onImageRemoveClicked()
}

class PreferenceSelectBackgroundImage @JvmOverloads constructor(
Copy link
Member

Choose a reason for hiding this comment

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

It looks good to me. Can you move this to SettingsFragment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@krmanik I tried moving this to SettingsFragment and encountered some issues.
So basically I had to update the reference in xml as follows :

<PreferenceCategory android:title="@string/background_image_title"
        app:allowDividerBelow="false">
            <view class="com.ichi2.anki.preferences.SettingsFragment$PreferenceSelectBackgroundImage"
                android:defaultValue="0"
                android:key="@string/pref_deck_picker_background_key"
                android:shouldDisableView="true"/>
    </PreferenceCategory>

which gives an error:

ACRA caught a InflateException for com.ichi2.anki.debug
android.view.InflateException: Binary XML file line #62: Error inflating class (not found)view

and on further searching I found:
https://stackoverflow.com/a/2100111/9062752

where it is mentioned in the comments -
" The only way round this I've found is to promote the static nested class to a full-blown class in its own file, which isn't ideal."

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Apr 13, 2024
Copy link
Contributor

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions bot added the Stale label Apr 27, 2024
@david-allison david-allison removed Needs Author Reply Waiting for a reply from the original author Stale labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: There's no direct button to remove the background image for deck screen
5 participants