Merge "Updating feedback setting to be global"
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.NOTIFICATION_FEEDBACK_ENABLED;
|
import static android.provider.Settings.Global.NOTIFICATION_FEEDBACK_ENABLED;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -82,20 +82,20 @@ public class AssistantFeedbackPreferenceController extends TogglePreferenceContr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
NOTIFICATION_FEEDBACK_ENABLED, OFF) == ON;
|
NOTIFICATION_FEEDBACK_ENABLED, OFF) == ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setChecked(boolean isChecked) {
|
public boolean setChecked(boolean isChecked) {
|
||||||
return Settings.Secure.putInt(mContext.getContentResolver(),
|
return Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
NOTIFICATION_FEEDBACK_ENABLED, isChecked ? ON : OFF);
|
NOTIFICATION_FEEDBACK_ENABLED, isChecked ? ON : OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SettingObserver extends ContentObserver {
|
class SettingObserver extends ContentObserver {
|
||||||
|
|
||||||
private final Uri NOTIFICATION_URI =
|
private final Uri NOTIFICATION_URI =
|
||||||
Settings.Secure.getUriFor(NOTIFICATION_FEEDBACK_ENABLED);
|
Settings.Global.getUriFor(NOTIFICATION_FEEDBACK_ENABLED);
|
||||||
|
|
||||||
private final Preference mPreference;
|
private final Preference mPreference;
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.NOTIFICATION_FEEDBACK_ENABLED;
|
import static android.provider.Settings.Global.NOTIFICATION_FEEDBACK_ENABLED;
|
||||||
|
|
||||||
import static com.android.settings.notification.AssistantFeedbackPreferenceController.OFF;
|
import static com.android.settings.notification.AssistantFeedbackPreferenceController.OFF;
|
||||||
import static com.android.settings.notification.AssistantFeedbackPreferenceController.ON;
|
import static com.android.settings.notification.AssistantFeedbackPreferenceController.ON;
|
||||||
@@ -76,7 +76,7 @@ public class AssistantFeedbackPreferenceControllerTest {
|
|||||||
public void updateState_preferenceSetCheckedWhenSettingIsOn() {
|
public void updateState_preferenceSetCheckedWhenSettingIsOn() {
|
||||||
final TwoStatePreference preference = mock(TwoStatePreference.class);
|
final TwoStatePreference preference = mock(TwoStatePreference.class);
|
||||||
final Context context = RuntimeEnvironment.application;
|
final Context context = RuntimeEnvironment.application;
|
||||||
Settings.Secure.putInt(context.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON);
|
Settings.Global.putInt(context.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON);
|
||||||
|
|
||||||
mController = new AssistantFeedbackPreferenceController(context, KEY);
|
mController = new AssistantFeedbackPreferenceController(context, KEY);
|
||||||
mController.updateState(preference);
|
mController.updateState(preference);
|
||||||
@@ -88,7 +88,7 @@ public class AssistantFeedbackPreferenceControllerTest {
|
|||||||
public void updateState_preferenceSetUncheckedWhenSettingIsOff() {
|
public void updateState_preferenceSetUncheckedWhenSettingIsOff() {
|
||||||
final TwoStatePreference preference = mock(TwoStatePreference.class);
|
final TwoStatePreference preference = mock(TwoStatePreference.class);
|
||||||
final Context context = RuntimeEnvironment.application;
|
final Context context = RuntimeEnvironment.application;
|
||||||
Settings.Secure.putInt(context.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF);
|
Settings.Global.putInt(context.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF);
|
||||||
|
|
||||||
mController = new AssistantFeedbackPreferenceController(context, KEY);
|
mController = new AssistantFeedbackPreferenceController(context, KEY);
|
||||||
mController.updateState(preference);
|
mController.updateState(preference);
|
||||||
@@ -98,24 +98,24 @@ public class AssistantFeedbackPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isChecked_settingIsOff_shouldReturnFalse() {
|
public void isChecked_settingIsOff_shouldReturnFalse() {
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF);
|
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF);
|
||||||
|
|
||||||
assertThat(mController.isChecked()).isFalse();
|
assertThat(mController.isChecked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isChecked_settingIsOn_shouldReturnTrue() {
|
public void isChecked_settingIsOn_shouldReturnTrue() {
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON);
|
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON);
|
||||||
|
|
||||||
assertThat(mController.isChecked()).isTrue();
|
assertThat(mController.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setChecked_setFalse_disablesSetting() {
|
public void setChecked_setFalse_disablesSetting() {
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON);
|
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON);
|
||||||
|
|
||||||
mController.setChecked(false);
|
mController.setChecked(false);
|
||||||
int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
|
int updatedValue = Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
NOTIFICATION_FEEDBACK_ENABLED, -1);
|
NOTIFICATION_FEEDBACK_ENABLED, -1);
|
||||||
|
|
||||||
assertThat(updatedValue).isEqualTo(OFF);
|
assertThat(updatedValue).isEqualTo(OFF);
|
||||||
@@ -123,10 +123,10 @@ public class AssistantFeedbackPreferenceControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setChecked_setTrue_enablesSetting() {
|
public void setChecked_setTrue_enablesSetting() {
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF);
|
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF);
|
||||||
|
|
||||||
mController.setChecked(true);
|
mController.setChecked(true);
|
||||||
int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
|
int updatedValue = Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
NOTIFICATION_FEEDBACK_ENABLED, -1);
|
NOTIFICATION_FEEDBACK_ENABLED, -1);
|
||||||
|
|
||||||
assertThat(updatedValue).isEqualTo(ON);
|
assertThat(updatedValue).isEqualTo(ON);
|
||||||
|
Reference in New Issue
Block a user