Skip to content

Attach permission-request to specific fragment#1150

Open
newhinton wants to merge 10 commits into
AppIntro:mainfrom
newhinton:main
Open

Attach permission-request to specific fragment#1150
newhinton wants to merge 10 commits into
AppIntro:mainfrom
newhinton:main

Conversation

@newhinton

@newhinton newhinton commented Oct 16, 2023

Copy link
Copy Markdown

fixes #1149

This switches permissionsMap to have a string index.
Then instead of the slide-id we use a tag (or id) to figure out if a request should be made

Todo:

  • Check if slideID works on tagged slides

allow a fragment to be added as permission-anchor
@newhinton newhinton changed the title attach permission-request via tag Attach permission-request to specific fragment Oct 17, 2023
Comment thread appintro/src/main/java/com/github/appintro/AppIntroBase.kt Outdated

@cortinico cortinico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would opt for having only the Int and Fragment overload and skip the ID approach at least for now.

Also @paolorotolo what's your take on this change?

Comment thread appintro/src/main/java/com/github/appintro/AppIntroFragment.kt Outdated
@newhinton

Copy link
Copy Markdown
Author

I don't think we need the id field here at all at this stage

As far as i can tell, fragments don't have an identifier. So this id is required to differentiate between each fragment for the permissionMap.
...though maybe we can abuse java itself. hashCode() should provide some unique string, so that could replace a dedicated ID implementation. Though i feel that this is not as maintainable and easy to understand.

I would opt for having only the Int and Fragment overload and skip the ID approach at least for now.

Sure, i can make the "String"-one private, but it is still internally required, so it cant be removed.

@cortinico

Copy link
Copy Markdown
Member

As far as i can tell, fragments don't have an identifier. So this id is required to differentiate between each fragment for the permissionMap.

In the method that accepts the Fragment, just check that instance against the private fragment list and get the index from there:

private val fragments: MutableList<Fragment> = mutableListOf()

There is no need to have extra index at all IMHO

@newhinton

Copy link
Copy Markdown
Author

As far as i can tell, fragments don't have an identifier. So this id is required to differentiate between each fragment for the permissionMap.

In the method that accepts the Fragment, just check that instance against the private fragment list and get the index from there:

private val fragments: MutableList<Fragment> = mutableListOf()

There is no need to have extra index at all IMHO

Oh yeah, that is actually better!

@newhinton

Copy link
Copy Markdown
Author

I have added a check and a small convenience wrapper that combines the addSlide and askForPermission-calls.

Comment thread appintro/src/main/java/com/github/appintro/AppIntroBase.kt Outdated
Comment thread appintro/src/main/java/com/github/appintro/AppIntroBase.kt Outdated
Comment thread appintro/src/main/java/com/github/appintro/AppIntroFragment.kt Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ask For Permission attached to specific slide

2 participants