[Settings] Disable gear button if user is not admin.
- Mobile settings include many settings which second user shall not modify, so make gear button disabled to avoid second user want to try. Bug: 184303943 Test: Maunal test passeded Test: atest passed. Change-Id: Ic04fa71772df4ac424965ad2ca95733b1e15d6a7
This commit is contained in:
@@ -29,7 +29,8 @@ import com.android.settingslib.RestrictedPreference;
|
||||
* A preference with a Gear on the side
|
||||
*/
|
||||
public class GearPreference extends RestrictedPreference implements View.OnClickListener {
|
||||
|
||||
// Default true for gear available even if the preference itself is disabled.
|
||||
protected boolean mGearState = true;
|
||||
private OnGearClickListener mOnGearClickListener;
|
||||
|
||||
public GearPreference(Context context, AttributeSet attrs) {
|
||||
@@ -41,6 +42,16 @@ public class GearPreference extends RestrictedPreference implements View.OnClick
|
||||
notifyChanged();
|
||||
}
|
||||
|
||||
/** Sets state of gear button. */
|
||||
public void setGearEnabled(boolean enabled) {
|
||||
mGearState = enabled;
|
||||
}
|
||||
|
||||
/** Gets state of gear button. */
|
||||
public boolean isGearEnabled() {
|
||||
return mGearState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSecondTargetResId() {
|
||||
return R.layout.preference_widget_gear;
|
||||
@@ -62,7 +73,8 @@ public class GearPreference extends RestrictedPreference implements View.OnClick
|
||||
gear.setVisibility(View.GONE);
|
||||
gear.setOnClickListener(null);
|
||||
}
|
||||
gear.setEnabled(true); // Make gear available even if the preference itself is disabled.
|
||||
// Make gear available even if the preference itself is disabled.
|
||||
gear.setEnabled(mGearState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user