-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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 Custom Vibrate Patterns to Settings #1169
Conversation
@@ -0,0 +1,151 @@ | |||
/** | |||
* Copyright (C) 2011 Whisper Systems |
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.
2014? :P
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.
hehe, fixed...
I tested it on my Nexus 4 and on a Android 2.3 emulator (couldn't test the vibrate, just the dialogs). What do you think? |
instead of having a checkbox to enable/disable vibrations, and then a separate preference for the vibration pattern, let's just have one preference where one of the options is "do not vibrate" or whatever |
Also, the preference description should display the configured value rather than describing what the preference is. |
@moxie0 Okay, you are right, thats better! I fixed it. edit: done now |
builder.setVibrate(new long[]{0,300,200,300,200,300}); | ||
} else if (vibratePattern.equals("3x_long")) { | ||
builder.setVibrate(new long[]{0,750,400,750,400,750}); | ||
} |
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.
Please have the stored preference be the eventual value that's passed to setVibrate so that you don't have to do this rule matching.
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.
okay, I changed the behaviour, can you check if its okay?
I squashed the commits into one and I think I fixed your points |
@@ -122,6 +122,8 @@ protected void onCreate(Bundle icicle) { | |||
.setOnPreferenceChangeListener(new ListSummaryListener()); | |||
this.findPreference(TextSecurePreferences.LED_BLINK_PREF) | |||
.setOnPreferenceChangeListener(new ListSummaryListener()); | |||
this.findPreference(TextSecurePreferences.VIBRATE_PREF) | |||
.setOnPreferenceChangeListener(new ListSummaryListener()); |
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 should be aligned like the lines above it.
I fixed the variable names and alignment |
<item>@string/preferences__pref_disabled</item> | ||
</string-array> | ||
|
||
<string-array name="pref_vibrate_values" translatable="false"> |
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.
default/custom/disabled are all translatable
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.
But this are the vaules, they are never displayed. The pref_vibrate_entries above are displayed. Should I really remove the translatable=false?
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.
no you're totally right, sorry I mixed the entries with values when I was speed reading :)
If I have a normal pattern set, choose custom and then hit "Cancel" in the Custom Vibrate Pattern dialog, my setting still shows up as "custom" when it should probably not be set. |
May be a good idea to also in the summary show the pattern they have set instead of just "Custom." Perhaps something like "Custom: 0,500,100,500" |
} | ||
} | ||
|
||
private void showDialog() { |
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.
reverse-indent :)
@mcginty I fixed the "Cancel" or back-button behaviour and added the custom value to the summary like this "Custom: 0,500,100,500" Sorry for the formatting, lower/uppercase and indent mistakes... |
also how are you going to migrate people's existing vibrate preference to this? |
@moxie0 The default pattern will be set regardless of the current setting. You are right, thats not good... |
Should I put it in the DatabaseUpgradeActivity to prevent a loss of the setting when vibrate is currently disabled? |
public static boolean isNotificationVibrateEnabled(Context context) { | ||
return getBooleanPreference(context, VIBRATE_PREF, true); | ||
public static String getNotificationVibrate(Context context) { | ||
return getStringPreference(context, VIBRATE_PREF, "default"); |
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.
Couldn't you just change this line to be backward compatible?
getStringPreference(context, VIBRATE_PREF, getBooleanPreference(context, VIBRATE_PREF, true) ? "default" : "disabled");
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.
yes, I thought of a check there too, but I thought its more clean when we don't check every time a notification arrives, and just once during update. But perhaps you're right and this is easier...
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 tried it, but the problem is that the setting will be displayed wrong nevertheless. getNotificationVibrate is not called when you open the settings and the summary is displayed. I think the real migration is the better way....
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.
On 06/20/2014 03:41 PM, agrajaghh wrote:
I tried it, but the problem is that the setting will be displayed wrong
nevertheless. getNotificationVibrate is not called when you open the
settings and the summary is displayed. I think the real migration is the
better way....
You can't be guaranteed that activity runs first. Migrations should be
avoided whenever possible.
The existing preference is now migrated in DatabaseUpgradeActivity |
@@ -243,8 +244,24 @@ public static String getNotificationRingtone(Context context) { | |||
return getStringPreference(context, RINGTONE_PREF, null); | |||
} | |||
|
|||
public static boolean isNotificationVibrateEnabled(Context context) { | |||
return getBooleanPreference(context, VIBRATE_PREF, true); | |||
public static void migrateNotificationVibrate(Context context) { |
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 added the migration here. Is this better?
love your vibration feature, thanks a lot. |
@agrajaghh Can we have a rebase, please? |
@agrajaghh Ah, I see what you mean. I've applied the patch and compiled successfully, and it looks great! Thank you for this! |
Thanks @agrajaghh, but I think we're going to skip this for now. It's a lot of code and includes a preference migration, and we're not sure that it's something the majority of users will find useful. We want to focus on customization for the core settings first. |
@agrajaghh Could you please rebase it anyway, for people who want this in their own build? |
@pejakm done at https://github.com/agrajaghh/TextSecure/tree/VibratePattern But I won't keep it up to date, sry... edit: not tested btw... |
Thank you very much! :) |
@agrajaghh Tested and works, thank you once again. |
Thanks for the rebase. It's very useful. I've had to use an automation tool Mladen Pejaković notifications@github.com schrieb am Fr., 12. Dez. 2014
|
I added the ability to choose custom vibrate Patterns. This fixes issue #230 You can chose between:
Of course I'm open to different standard vibrate patters or other changes.
This is my first pull request and I'm quite new to Java and Android, so please be gentle ;)