summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Shvadskiy <ashvadskiy@cyngn.com>2016-07-25 14:38:33 -0700
committerJoey Rizzoli <joey@cyanogenmoditalia.it>2016-10-17 16:40:07 +0200
commit3fcc9ef93726db542f6f459403c53530282c1f5d (patch)
tree0dea0883ea903b2e94c39feb20e209f8dcfef80f
parent739c76c93acbc0005b02414c29709922eb38c0dd (diff)
downloadandroid_packages_apps_Messaging-3fcc9ef93726db542f6f459403c53530282c1f5d.tar.gz
android_packages_apps_Messaging-3fcc9ef93726db542f6f459403c53530282c1f5d.tar.bz2
android_packages_apps_Messaging-3fcc9ef93726db542f6f459403c53530282c1f5d.zip
Use app settings for conversation settings if no custom set
Change-Id: I07adfd75c465ae40e477470d66587df21d560c4d issue-id: FEIJ-1291
-rw-r--r--src/com/android/messaging/datamodel/DatabaseHelper.java4
-rw-r--r--src/com/android/messaging/datamodel/data/ConversationListItemData.java7
-rw-r--r--src/com/android/messaging/datamodel/data/PeopleOptionsItemData.java7
-rw-r--r--src/com/android/messaging/util/NotificationUtil.java57
4 files changed, 69 insertions, 6 deletions
diff --git a/src/com/android/messaging/datamodel/DatabaseHelper.java b/src/com/android/messaging/datamodel/DatabaseHelper.java
index f16bb3c..77d0255 100644
--- a/src/com/android/messaging/datamodel/DatabaseHelper.java
+++ b/src/com/android/messaging/datamodel/DatabaseHelper.java
@@ -178,9 +178,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
+ ConversationColumns.OTHER_PARTICIPANT_NORMALIZED_DESTINATION + " TEXT, "
+ ConversationColumns.CURRENT_SELF_ID + " TEXT, "
+ ConversationColumns.PARTICIPANT_COUNT + " INT DEFAULT(0), "
- + ConversationColumns.NOTIFICATION_ENABLED + " INT DEFAULT(1), "
+ + ConversationColumns.NOTIFICATION_ENABLED + " INT DEFAULT(-1), "
+ ConversationColumns.NOTIFICATION_SOUND_URI + " TEXT, "
- + ConversationColumns.NOTIFICATION_VIBRATION + " INT DEFAULT(1), "
+ + ConversationColumns.NOTIFICATION_VIBRATION + " INT DEFAULT(-1), "
+ ConversationColumns.INCLUDE_EMAIL_ADDRESS + " INT DEFAULT(0), "
+ ConversationColumns.SMS_SERVICE_CENTER + " TEXT "
+ ");";
diff --git a/src/com/android/messaging/datamodel/data/ConversationListItemData.java b/src/com/android/messaging/datamodel/data/ConversationListItemData.java
index b2e6e1c..942baf2 100644
--- a/src/com/android/messaging/datamodel/data/ConversationListItemData.java
+++ b/src/com/android/messaging/datamodel/data/ConversationListItemData.java
@@ -29,6 +29,7 @@ import com.android.messaging.datamodel.DatabaseWrapper;
import com.android.messaging.datamodel.action.DeleteConversationAction;
import com.android.messaging.util.Assert;
import com.android.messaging.util.Dates;
+import com.android.messaging.util.NotificationUtil;
import com.google.common.base.Joiner;
import java.util.ArrayList;
@@ -90,9 +91,11 @@ public class ConversationListItemData {
INDEX_OTHER_PARTICIPANT_NORMALIZED_DESTINATION);
mSelfId = cursor.getString(INDEX_SELF_ID);
mParticipantCount = cursor.getInt(INDEX_PARTICIPANT_COUNT);
- mNotificationEnabled = cursor.getInt(INDEX_NOTIFICATION_ENABLED) == 1;
+ mNotificationEnabled = NotificationUtil.getConversationNotificationEnabled
+ (cursor.getInt(INDEX_NOTIFICATION_ENABLED));
mNotificationSoundUri = cursor.getString(INDEX_NOTIFICATION_SOUND_URI);
- mNotificationVibrate = cursor.getInt(INDEX_NOTIFICATION_VIBRATION) == 1;
+ mNotificationVibrate = NotificationUtil.getConversationNotificationVibrateEnabled(
+ cursor.getInt(INDEX_NOTIFICATION_VIBRATION));
mIncludeEmailAddress = cursor.getInt(INDEX_INCLUDE_EMAIL_ADDRESS) == 1;
mMessageStatus = cursor.getInt(INDEX_MESSAGE_STATUS);
mMessageRawTelephonyStatus = cursor.getInt(INDEX_MESSAGE_RAW_TELEPHONY_STATUS);
diff --git a/src/com/android/messaging/datamodel/data/PeopleOptionsItemData.java b/src/com/android/messaging/datamodel/data/PeopleOptionsItemData.java
index 5af6a30..b24ca55 100644
--- a/src/com/android/messaging/datamodel/data/PeopleOptionsItemData.java
+++ b/src/com/android/messaging/datamodel/data/PeopleOptionsItemData.java
@@ -24,6 +24,7 @@ import android.net.Uri;
import com.android.messaging.R;
import com.android.messaging.datamodel.data.ConversationListItemData.ConversationListViewColumns;
import com.android.messaging.util.Assert;
+import com.android.messaging.util.NotificationUtil;
import com.android.messaging.util.RingtoneUtil;
public class PeopleOptionsItemData {
@@ -78,7 +79,8 @@ public class PeopleOptionsItemData {
mItemId = settingType;
mOtherParticipant = otherParticipant;
- final boolean notificationEnabled = cursor.getInt(INDEX_NOTIFICATION_ENABLED) == 1;
+ final boolean notificationEnabled = NotificationUtil
+ .getConversationNotificationEnabled(cursor.getInt(INDEX_NOTIFICATION_ENABLED));
switch (settingType) {
case SETTING_NOTIFICATION_ENABLED:
mTitle = mContext.getString(R.string.notifications_enabled_conversation_pref_title);
@@ -104,7 +106,8 @@ public class PeopleOptionsItemData {
case SETTING_NOTIFICATION_VIBRATION:
mTitle = mContext.getString(R.string.notification_vibrate_pref_title);
- mChecked = cursor.getInt(INDEX_NOTIFICATION_VIBRATION) == 1;
+ mChecked = NotificationUtil.getConversationNotificationVibrateEnabled(
+ cursor.getInt(INDEX_NOTIFICATION_VIBRATION));
mEnabled = notificationEnabled;
break;
diff --git a/src/com/android/messaging/util/NotificationUtil.java b/src/com/android/messaging/util/NotificationUtil.java
new file mode 100644
index 0000000..6afa961
--- /dev/null
+++ b/src/com/android/messaging/util/NotificationUtil.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2016 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.messaging.util;
+
+import android.content.Context;
+
+import com.android.messaging.Factory;
+import com.android.messaging.R;
+
+public class NotificationUtil {
+ /**
+ * Get the final enabled status for notifications in this conversation, based on the given
+ * value, and the default (application-wide) value.
+ *
+ * @param conversationVal the custom value for this conversation, or -1 if it does not exist.
+ * @return whether notifications should be enabled for this conversation.
+ */
+ public static boolean getConversationNotificationEnabled(int conversationVal) {
+ return getEnabledCustomOrDefault(conversationVal, R.string.notifications_enabled_pref_key);
+ }
+
+ /**
+ * Get the final enabled status for notification vibration in this conversation, based on the
+ * given value and the default (application-wide) value.
+ *
+ * @param conversationVal the custom value for this conversation, or -1 if it does not exist.
+ * @return whether notification vibration should be enabled for this conversation.
+ */
+ public static boolean getConversationNotificationVibrateEnabled(int conversationVal) {
+ return getEnabledCustomOrDefault(conversationVal, R.string.notification_vibration_pref_key);
+ }
+
+ private static boolean getEnabledCustomOrDefault(int customVal, int keyRes) {
+ // Load default if we do not have a custom value set.
+ if (customVal == -1) {
+ final BuglePrefs prefs = BuglePrefs.getApplicationPrefs();
+ final Context context = Factory.get().getApplicationContext();
+ final String prefKey = context.getString(keyRes);
+ return prefs.getBoolean(prefKey, true);
+ } else {
+ return customVal == 1;
+ }
+ }
+}