added muting/unmuting conversation vibrate and toast msg #330
This commit is contained in:
Moez Bhatti
2016-01-24 00:39:44 -05:00
2 changed files with 15 additions and 1 deletions
@@ -20,6 +20,7 @@ import android.hardware.SensorManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Vibrator;
import android.provider.Telephony;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@@ -480,8 +481,10 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
case R.id.menu_notifications:
ConversationPrefsHelper conversationPrefs = new ConversationPrefsHelper(mContext, mThreadId);
conversationPrefs.putBoolean(SettingsFragment.NOTIFICATIONS, !conversationPrefs.getNotificationsEnabled());
boolean notificationMuted = conversationPrefs.getNotificationsEnabled();
conversationPrefs.putBoolean(SettingsFragment.NOTIFICATIONS, !notificationMuted);
mContext.invalidateOptionsMenu();
vibrateOnConversationStateChanged(notificationMuted);
return true;
case R.id.menu_details:
@@ -507,6 +510,14 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
startActivity(openDialerIntent);
}
private void vibrateOnConversationStateChanged(final boolean notificationMuted) {
final int vibrateTime = 70;
Toast.makeText(getActivity(), notificationMuted ?
R.string.notification_mute_off : R.string.notification_mute_on, Toast.LENGTH_SHORT).show();
Vibrator v = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(vibrateTime);
}
@Override
public void onPause() {
super.onPause();
+3
View File
@@ -373,6 +373,9 @@
<string name="mark_read">Mark as read</string>
<!--Notification action to call the sender of a message-->
<string name="call">Call</string>
<!-- Notification toast message -->
<string name="notification_mute_on">Notifications enabled</string>
<string name="notification_mute_off">Notifications disabled</string>
<!--Positive action button-->
<string name="yes">Yes</string>
<string name="add">Add</string>