-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add defaults to AppSettingsDialog and string res #74
Add defaults to AppSettingsDialog and string res #74
Conversation
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>
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 */) |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
@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>
@samtstern merged! |
@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"/> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)}. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
@SUPERCILEX can I merge this now? #73 was merged, any other dependencies? |
@samtstern I wanted to wait for #75 because it deprecates |
…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>
@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>
@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>
@samtstern I fixed some mistakes so it should be good now, but feel free to take another look at it! |
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 inAlertDialog
. Also, I thinkAppSettingsDialog
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.