Snap for 8408164 from ab8467e872 to tm-release
Change-Id: Ic5c1bf2ef5b6317202272c033dc1beb3ab4acfee
This commit is contained in:
@@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||||
<item android:state_enabled="false" android:color="?androidprv:attr/colorSurface"
|
|
||||||
android:alpha="?android:attr/disabledAlpha"/>
|
|
||||||
<item android:state_selected="true" android:color="?androidprv:attr/colorAccentPrimary"/>
|
<item android:state_selected="true" android:color="?androidprv:attr/colorAccentPrimary"/>
|
||||||
<item android:color="?androidprv:attr/colorSurface"/>
|
<item android:color="?androidprv:attr/colorSurface"/>
|
||||||
</selector>
|
</selector>
|
||||||
@@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
||||||
<item android:state_enabled="false" android:color="?android:attr/textColorPrimary"
|
|
||||||
android:alpha="?android:attr/disabledAlpha"/>
|
|
||||||
<item android:state_selected="true" android:color="?androidprv:attr/textColorOnAccent"/>
|
<item android:state_selected="true" android:color="?androidprv:attr/textColorOnAccent"/>
|
||||||
<item android:color="?android:attr/textColorPrimary"/>
|
<item android:color="?android:attr/textColorPrimary"/>
|
||||||
</selector>
|
</selector>
|
||||||
@@ -50,14 +50,13 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
* View holder for each {@link IDreamItem}.
|
* View holder for each {@link IDreamItem}.
|
||||||
*/
|
*/
|
||||||
private class DreamViewHolder extends RecyclerView.ViewHolder {
|
private class DreamViewHolder extends RecyclerView.ViewHolder {
|
||||||
private static final int VALUE_ENABLED_ALPHA = 255;
|
|
||||||
private final TextView mTitleView;
|
private final TextView mTitleView;
|
||||||
private final TextView mSummaryView;
|
private final TextView mSummaryView;
|
||||||
private final ImageView mPreviewView;
|
private final ImageView mPreviewView;
|
||||||
private final ImageView mPreviewPlaceholderView;
|
private final ImageView mPreviewPlaceholderView;
|
||||||
private final Button mCustomizeButton;
|
private final Button mCustomizeButton;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final int mDisabledAlphaValue;
|
private final float mDisabledAlphaValue;
|
||||||
|
|
||||||
DreamViewHolder(View view, Context context) {
|
DreamViewHolder(View view, Context context) {
|
||||||
super(view);
|
super(view);
|
||||||
@@ -67,7 +66,7 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
mTitleView = view.findViewById(R.id.title_text);
|
mTitleView = view.findViewById(R.id.title_text);
|
||||||
mSummaryView = view.findViewById(R.id.summary_text);
|
mSummaryView = view.findViewById(R.id.summary_text);
|
||||||
mCustomizeButton = view.findViewById(R.id.customize_button);
|
mCustomizeButton = view.findViewById(R.id.customize_button);
|
||||||
mDisabledAlphaValue = (int) (ColorUtil.getDisabledAlpha(context) * VALUE_ENABLED_ALPHA);
|
mDisabledAlphaValue = ColorUtil.getDisabledAlpha(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +92,6 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
mPreviewView.setImageDrawable(null);
|
mPreviewView.setImageDrawable(null);
|
||||||
mPreviewPlaceholderView.setVisibility(View.VISIBLE);
|
mPreviewPlaceholderView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
mPreviewView.setImageAlpha(getAlpha());
|
|
||||||
|
|
||||||
final Drawable icon = item.isActive()
|
final Drawable icon = item.isActive()
|
||||||
? mContext.getDrawable(R.drawable.ic_dream_check_circle)
|
? mContext.getDrawable(R.drawable.ic_dream_check_circle)
|
||||||
@@ -105,7 +103,6 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
final int iconSize = mContext.getResources().getDimensionPixelSize(
|
final int iconSize = mContext.getResources().getDimensionPixelSize(
|
||||||
R.dimen.dream_item_icon_size);
|
R.dimen.dream_item_icon_size);
|
||||||
icon.setBounds(0, 0, iconSize, iconSize);
|
icon.setBounds(0, 0, iconSize, iconSize);
|
||||||
icon.setAlpha(getAlpha());
|
|
||||||
mTitleView.setCompoundDrawablesRelative(icon, null, null, null);
|
mTitleView.setCompoundDrawablesRelative(icon, null, null, null);
|
||||||
|
|
||||||
if (item.isActive()) {
|
if (item.isActive()) {
|
||||||
@@ -130,10 +127,6 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
setEnabledStateOnViews(itemView, mEnabled);
|
setEnabledStateOnViews(itemView, mEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getAlpha() {
|
|
||||||
return mEnabled ? VALUE_ENABLED_ALPHA : mDisabledAlphaValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes sure the view (and any children) get the enabled state changed.
|
* Makes sure the view (and any children) get the enabled state changed.
|
||||||
*/
|
*/
|
||||||
@@ -145,6 +138,8 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||||||
for (int i = vg.getChildCount() - 1; i >= 0; i--) {
|
for (int i = vg.getChildCount() - 1; i >= 0; i--) {
|
||||||
setEnabledStateOnViews(vg.getChildAt(i), enabled);
|
setEnabledStateOnViews(vg.getChildAt(i), enabled);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
v.setAlpha(enabled ? 1 : mDisabledAlphaValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,8 @@
|
|||||||
package com.android.settings.localepicker;
|
package com.android.settings.localepicker;
|
||||||
|
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.app.LocaleManager;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.LocaleList;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.android.internal.app.LocalePickerWithRegion;
|
import com.android.internal.app.LocalePickerWithRegion;
|
||||||
@@ -34,7 +31,6 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
|||||||
implements LocalePickerWithRegion.LocaleSelectedListener {
|
implements LocalePickerWithRegion.LocaleSelectedListener {
|
||||||
|
|
||||||
private static final String PARENT_FRAGMENT_NAME = "localeListEditor";
|
private static final String PARENT_FRAGMENT_NAME = "localeListEditor";
|
||||||
private static final String TAG = "Calvin";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -51,25 +47,6 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
|||||||
.commit();
|
.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
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
if (item.getItemId() == android.R.id.home) {
|
if (item.getItemId() == android.R.id.home) {
|
||||||
@@ -81,16 +58,9 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocaleSelected(LocaleStore.LocaleInfo locale) {
|
public void onLocaleSelected(LocaleStore.LocaleInfo locale) {
|
||||||
/*final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.putExtra(LocaleListEditor.INTENT_LOCALE_KEY, locale);
|
intent.putExtra(LocaleListEditor.INTENT_LOCALE_KEY, locale);
|
||||||
setResult(RESULT_OK, intent);*/
|
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("");
|
|
||||||
}
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ package com.android.settings.notification.zen;
|
|||||||
import android.app.AutomaticZenRule;
|
import android.app.AutomaticZenRule;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Slog;
|
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
|
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
@@ -37,23 +34,19 @@ abstract class AbstractZenCustomRulePreferenceController extends
|
|||||||
super(context, key, lifecycle);
|
super(context, key, lifecycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateState(Preference preference) {
|
|
||||||
if (mId != null) {
|
|
||||||
mRule = mBackend.getAutomaticZenRule(mId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return mRule != null;
|
return mRule != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onResume(AutomaticZenRule rule, String id) {
|
public void setIdAndRule(String id, AutomaticZenRule rule) {
|
||||||
mId = id;
|
mId = id;
|
||||||
mRule = rule;
|
mRule = rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onResume() {
|
||||||
|
}
|
||||||
|
|
||||||
Bundle createBundle() {
|
Bundle createBundle() {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(ZenCustomRuleSettings.RULE_ID, mId);
|
bundle.putString(ZenCustomRuleSettings.RULE_ID, mId);
|
||||||
|
|||||||
@@ -37,10 +37,11 @@ abstract class ZenCustomRuleSettingsBase extends ZenModeSettingsBase {
|
|||||||
String mId;
|
String mId;
|
||||||
AutomaticZenRule mRule;
|
AutomaticZenRule mRule;
|
||||||
List<AbstractPreferenceController> mControllers = new ArrayList<>();
|
List<AbstractPreferenceController> mControllers = new ArrayList<>();
|
||||||
|
private boolean mIsFirstLaunch = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null if no preference category exists
|
* @return null if no preference category exists
|
||||||
*/
|
*/
|
||||||
abstract String getPreferenceCategoryKey();
|
abstract String getPreferenceCategoryKey();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,7 +50,7 @@ abstract class ZenCustomRuleSettingsBase extends ZenModeSettingsBase {
|
|||||||
Bundle bundle = getArguments();
|
Bundle bundle = getArguments();
|
||||||
if (bundle != null && bundle.containsKey(RULE_ID)) {
|
if (bundle != null && bundle.containsKey(RULE_ID)) {
|
||||||
mId = bundle.getString(RULE_ID);
|
mId = bundle.getString(RULE_ID);
|
||||||
mRule = mBackend.getAutomaticZenRule(mId);
|
updateRule();
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Rule id required to set custom dnd rule config settings");
|
Log.d(TAG, "Rule id required to set custom dnd rule config settings");
|
||||||
this.finish();
|
this.finish();
|
||||||
@@ -57,13 +58,32 @@ abstract class ZenCustomRuleSettingsBase extends ZenModeSettingsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onZenModeConfigChanged() {
|
public void onResume() {
|
||||||
super.onZenModeConfigChanged();
|
super.onResume();
|
||||||
updatePreferences();
|
updatePreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePreferences() {
|
@Override
|
||||||
|
public void onZenModeConfigChanged() {
|
||||||
|
super.onZenModeConfigChanged();
|
||||||
|
updatePreferences();
|
||||||
|
updatePreferenceStates();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateRule() {
|
||||||
mRule = mBackend.getAutomaticZenRule(mId);
|
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();
|
final PreferenceScreen screen = getPreferenceScreen();
|
||||||
String categoryKey = getPreferenceCategoryKey();
|
String categoryKey = getPreferenceCategoryKey();
|
||||||
if (categoryKey != null) {
|
if (categoryKey != null) {
|
||||||
@@ -78,10 +98,15 @@ abstract class ZenCustomRuleSettingsBase extends ZenModeSettingsBase {
|
|||||||
for (AbstractPreferenceController controller : mControllers) {
|
for (AbstractPreferenceController controller : mControllers) {
|
||||||
AbstractZenCustomRulePreferenceController zenRuleController =
|
AbstractZenCustomRulePreferenceController zenRuleController =
|
||||||
(AbstractZenCustomRulePreferenceController) controller;
|
(AbstractZenCustomRulePreferenceController) controller;
|
||||||
zenRuleController.onResume(mRule, mId);
|
zenRuleController.onResume();
|
||||||
zenRuleController.displayPreference(screen);
|
if (!mIsFirstLaunch) {
|
||||||
updatePreference(zenRuleController);
|
// In first launch, displayPreference() is already called in DashboardFragment's
|
||||||
|
// onCreate().
|
||||||
|
zenRuleController.displayPreference(screen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mIsFirstLaunch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -89,12 +114,6 @@ abstract class ZenCustomRuleSettingsBase extends ZenModeSettingsBase {
|
|||||||
return R.string.help_uri_interruptions;
|
return R.string.help_uri_interruptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
updatePreferences();
|
|
||||||
}
|
|
||||||
|
|
||||||
Bundle createZenRuleBundle() {
|
Bundle createZenRuleBundle() {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(RULE_ID, mId);
|
bundle.putString(RULE_ID, mId);
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package com.android.settings.notification.zen;
|
|||||||
|
|
||||||
import static com.android.settings.notification.zen.ZenPrioritySendersHelper.UNKNOWN;
|
import static com.android.settings.notification.zen.ZenPrioritySendersHelper.UNKNOWN;
|
||||||
|
|
||||||
import android.app.AutomaticZenRule;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.service.notification.ZenPolicy;
|
import android.service.notification.ZenPolicy;
|
||||||
@@ -79,8 +78,8 @@ public class ZenRulePrioritySendersPreferenceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume(AutomaticZenRule rule, String id) {
|
public void onResume() {
|
||||||
super.onResume(rule, id);
|
super.onResume();
|
||||||
if (mIsMessages) {
|
if (mIsMessages) {
|
||||||
updateChannelCounts();
|
updateChannelCounts();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ import android.app.AutomaticZenRule;
|
|||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.service.notification.ZenPolicy;
|
import android.service.notification.ZenPolicy;
|
||||||
|
|
||||||
import com.android.settings.notification.zen.AbstractZenCustomRulePreferenceController;
|
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
@@ -37,6 +35,6 @@ abstract class ZenRuleCustomPrefContrTestBase {
|
|||||||
|
|
||||||
void updateControllerZenPolicy(ZenPolicy policy) {
|
void updateControllerZenPolicy(ZenPolicy policy) {
|
||||||
mRule.setZenPolicy(policy);
|
mRule.setZenPolicy(policy);
|
||||||
getController().onResume(mRule, RULE_ID);
|
getController().setIdAndRule(RULE_ID, mRule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class ZenRulePreferenceControllerTest {
|
|||||||
assertTrue(mController.mRule == null);
|
assertTrue(mController.mRule == null);
|
||||||
assertTrue(mController.mId == null);
|
assertTrue(mController.mId == null);
|
||||||
|
|
||||||
mController.onResume(rule, id);
|
mController.setIdAndRule(id, rule);
|
||||||
|
|
||||||
assertEquals(mController.mId, id);
|
assertEquals(mController.mId, id);
|
||||||
assertEquals(mController.mRule, rule);
|
assertEquals(mController.mRule, rule);
|
||||||
|
|||||||
@@ -35,6 +35,6 @@ abstract class ZenRuleCustomPrefContrTestBase {
|
|||||||
|
|
||||||
void updateControllerZenPolicy(ZenPolicy policy) {
|
void updateControllerZenPolicy(ZenPolicy policy) {
|
||||||
mRule.setZenPolicy(policy);
|
mRule.setZenPolicy(policy);
|
||||||
getController().onResume(mRule, RULE_ID);
|
getController().setIdAndRule(RULE_ID, mRule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user