Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Conversation

SUPERCILEX
Copy link
Contributor

This change depends on #73 because I forgot to switch branches. I could try to cherry pick my commit if necessary.

Hey @samtstern my app is in the process of getting an Export as CSV option so I was like I'm definately going to use @samtstern's easypermissions lib and I'm already loving it!

Anyway, back to the PR. I noticed that you can't pass in a string res in AppSettingsDialog whereas you can in AlertDialog. Also, I think AppSettingsDialog should provide default values for the title and rationale because those are usually good enough. @samtstern If you don't agree with any of my statements above, please tell me and I can file to issue to discuss it more.

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
# Conflicts:
#	app/build.gradle
#	build.gradle
#	constants.gradle
#	easypermissions/build.gradle
#	gradle/wrapper/gradle-wrapper.properties
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
… Also allow use of string res instead of just strings

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
new AppSettingsDialog.Builder(this, getString(R.string.rationale_ask_again))
.setTitle(getString(R.string.title_settings_dialog))
.setPositiveButton(getString(R.string.setting))
.setNegativeButton(getString(R.string.cancel), null /* click listener */)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want to keep these with the default values just for the demo?

@@ -1,3 +1,3 @@
<manifest package="com.google.example.easypermissions">
<manifest package="pub.devrel.easypermissions">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to be a mistake: I couldn't get the project to find the R class with the old package name.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch.

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@SUPERCILEX
Copy link
Contributor Author

@samtstern I had to make lint happy in 041f92f which is weird because #73 didn't fail. I guess this lib is a little cleaner now! 😄

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@SUPERCILEX
Copy link
Contributor Author

@samtstern merged!

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@SUPERCILEX
Copy link
Contributor Author

@samtstern if this PR is good, could you hold off on merging? Thanks!

tools:context=".BasicActivity">

<Button
android:id="@+id/button_request"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Request" />
android:text="Request"
tools:ignore="HardcodedText"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are going to add @string resources in other places let's do it here as well rather than ignoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't do that because BasicActivity isn't part of the sample so it shouldn't pollute the strings.xml file. Do you agree with this or should I add it to the strings file anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, that's fine either way then.

@@ -1,3 +1,3 @@
<manifest package="com.google.example.easypermissions">
<manifest package="pub.devrel.easypermissions">
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch.


// Positive button text, or default
String positiveButtonText = TextUtils.isEmpty(positiveButton) ?
context.getString(android.R.string.ok) : positiveButton;
context.getString(R.string.settings) : positiveButton;
Copy link
Contributor

Choose a reason for hiding this comment

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

By changing this to be a string in the library but still using android.R.string.cancel for the negative, we could end up in a strange semi-translated state for non-english locales.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@samtstern What do you suggest doing? Should we keep android.R.string.ok or add a string for cancel so it isn't translated?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think let's keep android.R.string.ok for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

* @param rationale text explaining why the user should launch the app settings screen.
* @deprecated Use {@link #Builder(android.support.v4.app.Fragment)} with {@link
* #setRationale(String)} or {@link #setRationale(int)}.
Copy link
Contributor

Choose a reason for hiding this comment

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

The reason to include rationale in the builder constructor is that it implies that rationale is the only required option, the rest of the setters are optional.

I see that you're adding a default message. That should be OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I removed it because of that reason and also because have 6 different builder constructors would be crazy (a pair of two for the int and string overloads).

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@samtstern
Copy link
Contributor

@SUPERCILEX can I merge this now? #73 was merged, any other dependencies?

@SUPERCILEX
Copy link
Contributor Author

@samtstern I wanted to wait for #75 because it deprecates setNegativeButton. We could merge this one, but I'd have to either remove the int varient of setNegativeButton in #75 or immediately deprecate it. What do you think is the best option?

…nd-string-res

# Conflicts:
#	easypermissions/src/main/java/pub/devrel/easypermissions/AppSettingsDialog.java
#	easypermissions/src/main/java/pub/devrel/easypermissions/EasyPermissions.java
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@samtstern
Copy link
Contributor

@SUPERCILEX conflicts, obviously. Happy to merge this once fixed though.

…nd-string-res

# Conflicts:
#	app/src/main/java/pub/devrel/easypermissions/sample/MainActivity.java
#	easypermissions/src/main/AndroidManifest.xml
#	easypermissions/src/main/java/pub/devrel/easypermissions/AppSettingsDialog.java
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@SUPERCILEX
Copy link
Contributor Author

@samtstern Thanks for waiting on this! Could you just wait a tad bit longer? (I want to make sure I didn't make any stupid mistakes) Thanks!

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@SUPERCILEX
Copy link
Contributor Author

@samtstern I fixed some mistakes so it should be good now, but feel free to take another look at it!

@samtstern samtstern merged commit a11c288 into googlesamples:master Jan 25, 2017
@SUPERCILEX SUPERCILEX deleted the defaults-and-string-res branch January 25, 2017 00:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants