Merge "Fix bug where not all views are getting disabled alpha applied." into tm-dev
diff --git a/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java
index 70f7383..bcc55e3 100644
--- a/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java
+++ b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java
@@ -17,11 +17,8 @@
package com.android.settings.localepicker;
import android.app.FragmentTransaction;
-import android.app.LocaleManager;
import android.content.Intent;
import android.os.Bundle;
-import android.os.LocaleList;
-import android.util.Log;
import android.view.MenuItem;
import com.android.internal.app.LocalePickerWithRegion;
@@ -34,7 +31,6 @@
implements LocalePickerWithRegion.LocaleSelectedListener {
private static final String PARENT_FRAGMENT_NAME = "localeListEditor";
- private static final String TAG = "Calvin";
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -51,25 +47,6 @@
.commit();
}
- public void setAppDefaultLocale(String languageTag) {
- if (languageTag.isEmpty()) {
- Log.w(TAG, "[setAppDefaultLocale] No language tag.");
- return;
- }
- setAppDefaultLocale(LocaleList.forLanguageTags(languageTag));
- }
-
- /** Sets per app's default language to system. */
- public void setAppDefaultLocale(LocaleList localeList) {
- LocaleManager mLocaleManager = getSystemService(LocaleManager.class);
- if (mLocaleManager == null) {
- Log.w(TAG, "LocaleManager is null, and cannot set the app locale up.");
- return;
- }
- mLocaleManager.setApplicationLocales("com.android.vending", localeList);
- }
-
-
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
@@ -81,16 +58,9 @@
@Override
public void onLocaleSelected(LocaleStore.LocaleInfo locale) {
- /*final Intent intent = new Intent();
+ final Intent intent = new Intent();
intent.putExtra(LocaleListEditor.INTENT_LOCALE_KEY, locale);
- setResult(RESULT_OK, intent);*/
- if(locale != null) {
- Log.d("Calvin", "onLocaleSelected " + locale.getLocale().toLanguageTag());
- setAppDefaultLocale(locale.getLocale().toLanguageTag());
- } else {
- Log.d("Calvin", "onLocaleSelected null");
- setAppDefaultLocale("");
- }
+ setResult(RESULT_OK, intent);
finish();
}
diff --git a/src/com/android/settings/notification/zen/AbstractZenCustomRulePreferenceController.java b/src/com/android/settings/notification/zen/AbstractZenCustomRulePreferenceController.java
index bf70080..f6997c6 100644
--- a/src/com/android/settings/notification/zen/AbstractZenCustomRulePreferenceController.java
+++ b/src/com/android/settings/notification/zen/AbstractZenCustomRulePreferenceController.java
@@ -19,9 +19,6 @@
import android.app.AutomaticZenRule;
import android.content.Context;
import android.os.Bundle;
-import android.util.Slog;
-
-import androidx.preference.Preference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -38,22 +35,18 @@
}
@Override
- public void updateState(Preference preference) {
- if (mId != null) {
- mRule = mBackend.getAutomaticZenRule(mId);
- }
- }
-
- @Override
public boolean isAvailable() {
return mRule != null;
}
- public void onResume(AutomaticZenRule rule, String id) {
+ public void setIdAndRule(String id, AutomaticZenRule rule) {
mId = id;
mRule = rule;
}
+ public void onResume() {
+ }
+
Bundle createBundle() {
Bundle bundle = new Bundle();
bundle.putString(ZenCustomRuleSettings.RULE_ID, mId);
diff --git a/src/com/android/settings/notification/zen/ZenCustomRuleSettingsBase.java b/src/com/android/settings/notification/zen/ZenCustomRuleSettingsBase.java
index 28a3046..b417e03 100644
--- a/src/com/android/settings/notification/zen/ZenCustomRuleSettingsBase.java
+++ b/src/com/android/settings/notification/zen/ZenCustomRuleSettingsBase.java
@@ -37,10 +37,11 @@
String mId;
AutomaticZenRule mRule;
List<AbstractPreferenceController> mControllers = new ArrayList<>();
+ private boolean mIsFirstLaunch = true;
/**
* @return null if no preference category exists
- */
+ */
abstract String getPreferenceCategoryKey();
@Override
@@ -49,7 +50,7 @@
Bundle bundle = getArguments();
if (bundle != null && bundle.containsKey(RULE_ID)) {
mId = bundle.getString(RULE_ID);
- mRule = mBackend.getAutomaticZenRule(mId);
+ updateRule();
} else {
Log.d(TAG, "Rule id required to set custom dnd rule config settings");
this.finish();
@@ -57,13 +58,32 @@
}
@Override
- public void onZenModeConfigChanged() {
- super.onZenModeConfigChanged();
+ public void onResume() {
+ super.onResume();
updatePreferences();
}
- public void updatePreferences() {
+ @Override
+ public void onZenModeConfigChanged() {
+ super.onZenModeConfigChanged();
+ updatePreferences();
+ updatePreferenceStates();
+ }
+
+ private void updateRule() {
mRule = mBackend.getAutomaticZenRule(mId);
+ for (AbstractPreferenceController controller : mControllers) {
+ AbstractZenCustomRulePreferenceController zenRuleController =
+ (AbstractZenCustomRulePreferenceController) controller;
+ zenRuleController.setIdAndRule(mId, mRule);
+ }
+ }
+
+ public void updatePreferences() {
+ if (!mIsFirstLaunch) {
+ updateRule();
+ }
+
final PreferenceScreen screen = getPreferenceScreen();
String categoryKey = getPreferenceCategoryKey();
if (categoryKey != null) {
@@ -78,10 +98,15 @@
for (AbstractPreferenceController controller : mControllers) {
AbstractZenCustomRulePreferenceController zenRuleController =
(AbstractZenCustomRulePreferenceController) controller;
- zenRuleController.onResume(mRule, mId);
- zenRuleController.displayPreference(screen);
- updatePreference(zenRuleController);
+ zenRuleController.onResume();
+ if (!mIsFirstLaunch) {
+ // In first launch, displayPreference() is already called in DashboardFragment's
+ // onCreate().
+ zenRuleController.displayPreference(screen);
+ }
}
+
+ mIsFirstLaunch = false;
}
@Override
@@ -89,12 +114,6 @@
return R.string.help_uri_interruptions;
}
- @Override
- public void onResume() {
- super.onResume();
- updatePreferences();
- }
-
Bundle createZenRuleBundle() {
Bundle bundle = new Bundle();
bundle.putString(RULE_ID, mId);
diff --git a/src/com/android/settings/notification/zen/ZenRulePrioritySendersPreferenceController.java b/src/com/android/settings/notification/zen/ZenRulePrioritySendersPreferenceController.java
index cee496e..8f5e0e1 100644
--- a/src/com/android/settings/notification/zen/ZenRulePrioritySendersPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenRulePrioritySendersPreferenceController.java
@@ -18,7 +18,6 @@
import static com.android.settings.notification.zen.ZenPrioritySendersHelper.UNKNOWN;
-import android.app.AutomaticZenRule;
import android.content.Context;
import android.os.AsyncTask;
import android.service.notification.ZenPolicy;
@@ -79,8 +78,8 @@
}
@Override
- public void onResume(AutomaticZenRule rule, String id) {
- super.onResume(rule, id);
+ public void onResume() {
+ super.onResume();
if (mIsMessages) {
updateChannelCounts();
}
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenRuleCustomPrefContrTestBase.java b/tests/robotests/src/com/android/settings/notification/zen/ZenRuleCustomPrefContrTestBase.java
index 8c9cfc0..339ba8e 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenRuleCustomPrefContrTestBase.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenRuleCustomPrefContrTestBase.java
@@ -20,8 +20,6 @@
import android.app.NotificationManager;
import android.service.notification.ZenPolicy;
-import com.android.settings.notification.zen.AbstractZenCustomRulePreferenceController;
-
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@@ -37,6 +35,6 @@
void updateControllerZenPolicy(ZenPolicy policy) {
mRule.setZenPolicy(policy);
- getController().onResume(mRule, RULE_ID);
+ getController().setIdAndRule(RULE_ID, mRule);
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenRulePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenRulePreferenceControllerTest.java
index 10eae06..514b4f6 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenRulePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenRulePreferenceControllerTest.java
@@ -78,7 +78,7 @@
assertTrue(mController.mRule == null);
assertTrue(mController.mId == null);
- mController.onResume(rule, id);
+ mController.setIdAndRule(id, rule);
assertEquals(mController.mId, id);
assertEquals(mController.mRule, rule);
diff --git a/tests/unit/src/com/android/settings/notification/zen/ZenRuleCustomPrefContrTestBase.java b/tests/unit/src/com/android/settings/notification/zen/ZenRuleCustomPrefContrTestBase.java
index 53ad7c5..c263943 100644
--- a/tests/unit/src/com/android/settings/notification/zen/ZenRuleCustomPrefContrTestBase.java
+++ b/tests/unit/src/com/android/settings/notification/zen/ZenRuleCustomPrefContrTestBase.java
@@ -35,6 +35,6 @@
void updateControllerZenPolicy(ZenPolicy policy) {
mRule.setZenPolicy(policy);
- getController().onResume(mRule, RULE_ID);
+ getController().setIdAndRule(RULE_ID, mRule);
}
}