Merge "Apply policy transparency to HotspotCondition and WiFi settings..." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
295f1060e9
@@ -74,13 +74,13 @@ public class ConditionAdapterUtils {
|
||||
expand.setOnClickListener(onExpandListener);
|
||||
|
||||
View detailGroup = view.itemView.findViewById(R.id.detail_group);
|
||||
CharSequence[] actions = condition.getActions();
|
||||
if (isExpanded != (detailGroup.getVisibility() == View.VISIBLE)) {
|
||||
animateChange(view.itemView, view.itemView.findViewById(R.id.content),
|
||||
detailGroup, isExpanded);
|
||||
detailGroup, isExpanded, actions.length > 0);
|
||||
}
|
||||
if (isExpanded) {
|
||||
view.summary.setText(condition.getSummary());
|
||||
CharSequence[] actions = condition.getActions();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Button button = (Button) detailGroup.findViewById(i == 0
|
||||
? R.id.first_action : R.id.second_action);
|
||||
@@ -105,7 +105,9 @@ public class ConditionAdapterUtils {
|
||||
}
|
||||
|
||||
private static void animateChange(final View view, final View content,
|
||||
final View detailGroup, final boolean visible) {
|
||||
final View detailGroup, final boolean visible, final boolean hasButtons) {
|
||||
setViewVisibility(detailGroup, R.id.divider, hasButtons);
|
||||
setViewVisibility(detailGroup, R.id.buttonBar, hasButtons);
|
||||
final int beforeBottom = content.getBottom();
|
||||
setHeight(detailGroup, visible ? LayoutParams.WRAP_CONTENT : 0);
|
||||
detailGroup.setVisibility(View.VISIBLE);
|
||||
@@ -138,4 +140,11 @@ public class ConditionAdapterUtils {
|
||||
params.height = height;
|
||||
detailGroup.setLayoutParams(params);
|
||||
}
|
||||
|
||||
private static void setViewVisibility(View containerView, int viewId, boolean visible) {
|
||||
View view = containerView.findViewById(viewId);
|
||||
if (view != null) {
|
||||
view.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,15 @@ import android.content.Intent;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TetherSettings;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
import com.android.settingslib.TetherUtil;
|
||||
|
||||
public class HotspotCondition extends Condition {
|
||||
@@ -74,7 +79,12 @@ public class HotspotCondition extends Condition {
|
||||
|
||||
@Override
|
||||
public CharSequence[] getActions() {
|
||||
return new CharSequence[] { mManager.getContext().getString(R.string.condition_turn_off) };
|
||||
final Context context = mManager.getContext();
|
||||
if (RestrictedLockUtils.hasBaseUserRestriction(context,
|
||||
UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.myUserId())) {
|
||||
return new CharSequence[0];
|
||||
}
|
||||
return new CharSequence[] { context.getString(R.string.condition_turn_off) };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,8 +96,15 @@ public class HotspotCondition extends Condition {
|
||||
@Override
|
||||
public void onActionClick(int index) {
|
||||
if (index == 0) {
|
||||
TetherUtil.setWifiTethering(false, mManager.getContext());
|
||||
setActive(false);
|
||||
final Context context = mManager.getContext();
|
||||
final EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(context,
|
||||
UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.myUserId());
|
||||
if (admin != null) {
|
||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(context, admin);
|
||||
} else {
|
||||
TetherUtil.setWifiTethering(false, context);
|
||||
setActive(false);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected index " + index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user