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"
|
||||
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:color="?androidprv:attr/colorSurface"/>
|
||||
</selector>
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/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:color="?android:attr/textColorPrimary"/>
|
||||
</selector>
|
||||
@@ -50,14 +50,13 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
* View holder for each {@link IDreamItem}.
|
||||
*/
|
||||
private class DreamViewHolder extends RecyclerView.ViewHolder {
|
||||
private static final int VALUE_ENABLED_ALPHA = 255;
|
||||
private final TextView mTitleView;
|
||||
private final TextView mSummaryView;
|
||||
private final ImageView mPreviewView;
|
||||
private final ImageView mPreviewPlaceholderView;
|
||||
private final Button mCustomizeButton;
|
||||
private final Context mContext;
|
||||
private final int mDisabledAlphaValue;
|
||||
private final float mDisabledAlphaValue;
|
||||
|
||||
DreamViewHolder(View view, Context context) {
|
||||
super(view);
|
||||
@@ -67,7 +66,7 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
mTitleView = view.findViewById(R.id.title_text);
|
||||
mSummaryView = view.findViewById(R.id.summary_text);
|
||||
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);
|
||||
mPreviewPlaceholderView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mPreviewView.setImageAlpha(getAlpha());
|
||||
|
||||
final Drawable icon = item.isActive()
|
||||
? 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(
|
||||
R.dimen.dream_item_icon_size);
|
||||
icon.setBounds(0, 0, iconSize, iconSize);
|
||||
icon.setAlpha(getAlpha());
|
||||
mTitleView.setCompoundDrawablesRelative(icon, null, null, null);
|
||||
|
||||
if (item.isActive()) {
|
||||
@@ -130,10 +127,6 @@ public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
setEnabledStateOnViews(itemView, mEnabled);
|
||||
}
|
||||
|
||||
private int getAlpha() {
|
||||
return mEnabled ? VALUE_ENABLED_ALPHA : mDisabledAlphaValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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--) {
|
||||
setEnabledStateOnViews(vg.getChildAt(i), enabled);
|
||||
}
|
||||
} else {
|
||||
v.setAlpha(enabled ? 1 : mDisabledAlphaValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
||||
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 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
||||
.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 @@ public class LocalePickerWithRegionActivity extends SettingsBaseActivity
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@ package com.android.settings.notification.zen;
|
||||
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;
|
||||
@@ -37,23 +34,19 @@ abstract class AbstractZenCustomRulePreferenceController extends
|
||||
super(context, key, lifecycle);
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
@@ -37,6 +37,7 @@ abstract class ZenCustomRuleSettingsBase extends ZenModeSettingsBase {
|
||||
String mId;
|
||||
AutomaticZenRule mRule;
|
||||
List<AbstractPreferenceController> mControllers = new ArrayList<>();
|
||||
private boolean mIsFirstLaunch = true;
|
||||
|
||||
/**
|
||||
* @return null if no preference category exists
|
||||
@@ -49,7 +50,7 @@ abstract class ZenCustomRuleSettingsBase extends ZenModeSettingsBase {
|
||||
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 @@ abstract class ZenCustomRuleSettingsBase extends ZenModeSettingsBase {
|
||||
}
|
||||
|
||||
@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,23 +98,22 @@ abstract class ZenCustomRuleSettingsBase extends ZenModeSettingsBase {
|
||||
for (AbstractPreferenceController controller : mControllers) {
|
||||
AbstractZenCustomRulePreferenceController zenRuleController =
|
||||
(AbstractZenCustomRulePreferenceController) controller;
|
||||
zenRuleController.onResume(mRule, mId);
|
||||
zenRuleController.onResume();
|
||||
if (!mIsFirstLaunch) {
|
||||
// In first launch, displayPreference() is already called in DashboardFragment's
|
||||
// onCreate().
|
||||
zenRuleController.displayPreference(screen);
|
||||
updatePreference(zenRuleController);
|
||||
}
|
||||
}
|
||||
|
||||
mIsFirstLaunch = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHelpResource() {
|
||||
return R.string.help_uri_interruptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updatePreferences();
|
||||
}
|
||||
|
||||
Bundle createZenRuleBundle() {
|
||||
Bundle bundle = new Bundle();
|
||||
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 android.app.AutomaticZenRule;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.service.notification.ZenPolicy;
|
||||
@@ -79,8 +78,8 @@ public class ZenRulePrioritySendersPreferenceController
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(AutomaticZenRule rule, String id) {
|
||||
super.onResume(rule, id);
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (mIsMessages) {
|
||||
updateChannelCounts();
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ import android.app.AutomaticZenRule;
|
||||
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 @@ abstract class ZenRuleCustomPrefContrTestBase {
|
||||
|
||||
void updateControllerZenPolicy(ZenPolicy 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.mId == null);
|
||||
|
||||
mController.onResume(rule, id);
|
||||
mController.setIdAndRule(id, rule);
|
||||
|
||||
assertEquals(mController.mId, id);
|
||||
assertEquals(mController.mRule, rule);
|
||||
|
||||
@@ -35,6 +35,6 @@ abstract class ZenRuleCustomPrefContrTestBase {
|
||||
|
||||
void updateControllerZenPolicy(ZenPolicy policy) {
|
||||
mRule.setZenPolicy(policy);
|
||||
getController().onResume(mRule, RULE_ID);
|
||||
getController().setIdAndRule(RULE_ID, mRule);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user