Merge "Adjust restricted lock positions as per new design." into nyc-dev

This commit is contained in:
Sudheer Shanka
2016-03-10 15:58:15 +00:00
committed by Android (Google) Code Review
7 changed files with 91 additions and 11 deletions

View File

@@ -130,7 +130,7 @@ public class UsbModeChooserActivity extends Activity {
private void inflateOption(final int mode, boolean selected, LinearLayout container,
final boolean disallowedByAdmin) {
View v = mLayoutInflater.inflate(R.layout.radio_with_summary, container, false);
View v = mLayoutInflater.inflate(R.layout.restricted_radio_with_summary, container, false);
TextView titleView = (TextView) v.findViewById(android.R.id.title);
titleView.setText(getTitle(mode));
@@ -139,7 +139,7 @@ public class UsbModeChooserActivity extends Activity {
if (disallowedByAdmin) {
if (mEnforcedAdmin != null) {
setDisabledByAdmin(titleView, summaryView);
setDisabledByAdmin(v, titleView, summaryView);
} else {
return;
}
@@ -164,12 +164,11 @@ public class UsbModeChooserActivity extends Activity {
container.addView(v);
}
private void setDisabledByAdmin(TextView titleView, TextView summaryView) {
private void setDisabledByAdmin(View rootView, TextView titleView, TextView summaryView) {
if (mEnforcedAdmin != null) {
titleView.setEnabled(false);
summaryView.setEnabled(false);
RestrictedLockUtils.setTextViewPadlock(this,
titleView, true /* showPadlock */);
rootView.findViewById(R.id.restricted_icon).setVisibility(View.VISIBLE);
Drawable[] compoundDrawables = titleView.getCompoundDrawablesRelative();
compoundDrawables[0 /* start */].mutate().setColorFilter(
getColor(R.color.disabled_text_color), PorterDuff.Mode.MULTIPLY);

View File

@@ -58,6 +58,7 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
private final TextAppearanceSpan mSummarySpan;
private ToggleSwitch mSwitch;
private View mRestrictedIcon;
private TextView mTextView;
private String mLabel;
private String mSummary;
@@ -122,6 +123,8 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
}
});
mRestrictedIcon = findViewById(R.id.restricted_icon);
setOnClickListener(this);
// Default is hide
@@ -189,12 +192,14 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
if (admin != null) {
super.setEnabled(true);
mDisabledByAdmin = true;
RestrictedLockUtils.setTextViewPadlock(mContext, mTextView, true);
mTextView.setEnabled(false);
mSwitch.setEnabled(false);
mSwitch.setVisibility(View.GONE);
mRestrictedIcon.setVisibility(View.VISIBLE);
} else {
mDisabledByAdmin = false;
RestrictedLockUtils.setTextViewPadlock(mContext, mTextView, false);
mSwitch.setVisibility(View.VISIBLE);
mRestrictedIcon.setVisibility(View.GONE);
setEnabled(true);
}
}