Merge "Make Settings use system-api restricted icon."
This commit is contained in:
committed by
Android (Google) Code Review
commit
b009e89e4f
@@ -27,7 +27,8 @@
|
|||||||
<ImageView android:id="@+id/admin_support_icon"
|
<ImageView android:id="@+id/admin_support_icon"
|
||||||
android:layout_width="@dimen/admin_details_dialog_icon_size"
|
android:layout_width="@dimen/admin_details_dialog_icon_size"
|
||||||
android:layout_height="@dimen/admin_details_dialog_icon_size"
|
android:layout_height="@dimen/admin_details_dialog_icon_size"
|
||||||
android:src="@drawable/ic_info"
|
android:tint="?android:attr/colorAccent"
|
||||||
|
android:src="@*android:drawable/ic_info"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:contentDescription="@null" />
|
android:contentDescription="@null" />
|
||||||
<TextView android:id="@+id/admin_support_dialog_title"
|
<TextView android:id="@+id/admin_support_dialog_title"
|
||||||
|
@@ -36,10 +36,11 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/restricted_lock_icon_remote_input"
|
android:id="@+id/restricted_lock_icon_remote_input"
|
||||||
android:layout_width="@dimen/restricted_icon_size"
|
android:layout_width="@*android:dimen/config_restricted_icon_size"
|
||||||
android:layout_height="@dimen/restricted_icon_size"
|
android:layout_height="@*android:dimen/config_restricted_icon_size"
|
||||||
android:src="@drawable/ic_info"
|
android:tint="?android:attr/colorAccent"
|
||||||
|
android:src="@*android:drawable/ic_info"
|
||||||
android:layout_marginEnd="?android:attr/dialogPreferredPadding"
|
android:layout_marginEnd="?android:attr/dialogPreferredPadding"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:scaleType="centerInside" />
|
android:scaleType="centerInside" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -77,7 +77,7 @@
|
|||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingLeft="16dip"
|
android:paddingLeft="16dip"
|
||||||
android:contentDescription="@string/printer_info_desc"
|
android:contentDescription="@string/printer_info_desc"
|
||||||
android:src="@drawable/ic_info"
|
android:src="@*android:drawable/ic_info"
|
||||||
android:tint="?android:attr/colorControlNormal"
|
android:tint="?android:attr/colorControlNormal"
|
||||||
android:tintMode="src_in" />
|
android:tintMode="src_in" />
|
||||||
|
|
||||||
|
@@ -37,11 +37,12 @@
|
|||||||
android:ellipsize="marquee" />
|
android:ellipsize="marquee" />
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/restricted_lock_icon"
|
android:id="@+id/restricted_lock_icon"
|
||||||
android:layout_width="@dimen/restricted_icon_size"
|
android:layout_width="@*android:dimen/config_restricted_icon_size"
|
||||||
android:layout_height="@dimen/restricted_icon_size"
|
android:layout_height="@*android:dimen/config_restricted_icon_size"
|
||||||
android:src="@drawable/ic_info"
|
android:tint="?android:attr/colorAccent"
|
||||||
|
android:src="@*android:drawable/ic_info"
|
||||||
android:layout_marginLeft="@dimen/restricted_icon_padding"
|
android:layout_marginLeft="@dimen/restricted_icon_padding"
|
||||||
android:baselineAlignBottom="true"
|
android:baselineAlignBottom="true"
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</com.android.settings.CheckableLinearLayout>
|
</com.android.settings.CheckableLinearLayout>
|
||||||
|
@@ -34,10 +34,11 @@
|
|||||||
android:layout_alignParentLeft="true" />
|
android:layout_alignParentLeft="true" />
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/restricted_icon"
|
android:id="@+id/restricted_icon"
|
||||||
android:layout_width="@dimen/restricted_icon_size"
|
android:layout_width="@*android:dimen/config_restricted_icon_size"
|
||||||
android:layout_height="@dimen/restricted_icon_size"
|
android:layout_height="@*android:dimen/config_restricted_icon_size"
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:src="@drawable/ic_info"
|
android:tint="?android:attr/colorAccent"
|
||||||
|
android:src="@*android:drawable/ic_info"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@@ -41,10 +41,11 @@
|
|||||||
android:ellipsize="marquee" />
|
android:ellipsize="marquee" />
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/restricted_icon"
|
android:id="@+id/restricted_icon"
|
||||||
android:layout_width="@dimen/restricted_icon_size"
|
android:layout_width="@*android:dimen/config_restricted_icon_size"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
android:src="@drawable/ic_info"
|
android:tint="?android:attr/colorAccent"
|
||||||
|
android:src="@*android:drawable/ic_info"
|
||||||
android:layout_marginLeft="@dimen/restricted_icon_padding"
|
android:layout_marginLeft="@dimen/restricted_icon_padding"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</com.android.settings.CheckableLinearLayout>
|
</com.android.settings.CheckableLinearLayout>
|
||||||
@@ -59,4 +60,4 @@
|
|||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:maxLines="10" />
|
android:maxLines="10" />
|
||||||
|
|
||||||
</com.android.settings.CheckableLinearLayout>
|
</com.android.settings.CheckableLinearLayout>
|
||||||
|
@@ -26,11 +26,12 @@
|
|||||||
android:layout_height="?android:attr/listPreferredItemHeightSmall"
|
android:layout_height="?android:attr/listPreferredItemHeightSmall"
|
||||||
android:ellipsize="marquee" />
|
android:ellipsize="marquee" />
|
||||||
<ImageView android:id="@+id/restricted_icon"
|
<ImageView android:id="@+id/restricted_icon"
|
||||||
android:layout_width="@dimen/restricted_icon_size"
|
android:layout_width="@*android:dimen/config_restricted_icon_size"
|
||||||
android:layout_height="@dimen/restricted_icon_size"
|
android:layout_height="@*android:dimen/config_restricted_icon_size"
|
||||||
android:src="@drawable/ic_info"
|
android:tint="?android:attr/colorAccent"
|
||||||
|
android:src="@*android:drawable/ic_info"
|
||||||
android:baselineAlignBottom="true"
|
android:baselineAlignBottom="true"
|
||||||
android:layout_marginEnd="@dimen/restricted_icon_padding"
|
android:layout_marginEnd="@dimen/restricted_icon_padding"
|
||||||
android:gravity="end|center_vertical"
|
android:gravity="end|center_vertical"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -29,24 +29,23 @@
|
|||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:textAppearance="@style/TextAppearance.Switch"
|
android:textAppearance="@style/TextAppearance.Switch"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textAlignment="viewStart" />
|
android:textAlignment="viewStart"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/restricted_icon"
|
android:id="@+id/restricted_icon"
|
||||||
android:layout_width="@dimen/restricted_icon_size"
|
android:layout_width="@dimen/restricted_icon_size"
|
||||||
android:layout_height="@dimen/restricted_icon_size"
|
android:layout_height="@dimen/restricted_icon_size"
|
||||||
android:src="@drawable/ic_info"
|
android:tint="?android:attr/colorAccent"
|
||||||
android:theme="@android:style/Theme.Material"
|
android:theme="@android:style/Theme.Material"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginEnd="@dimen/restricted_icon_margin_end"
|
android:layout_marginEnd="@dimen/restricted_icon_margin_end"/>
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<com.android.settings.widget.ToggleSwitch
|
<com.android.settings.widget.ToggleSwitch
|
||||||
android:id="@+id/switch_widget"
|
android:id="@+id/switch_widget"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:theme="@style/Widget.SwitchBar.Switch" />
|
android:theme="@style/Widget.SwitchBar.Switch"/>
|
||||||
|
|
||||||
</merge>
|
</merge>
|
||||||
|
|
||||||
|
@@ -101,6 +101,7 @@
|
|||||||
<attr name="switchBarMarginEnd" format="dimension" />
|
<attr name="switchBarMarginEnd" format="dimension" />
|
||||||
<attr name="switchBarBackgroundColor" format="color" />
|
<attr name="switchBarBackgroundColor" format="color" />
|
||||||
<attr name="switchBarBackgroundActivatedColor" format="color" />
|
<attr name="switchBarBackgroundActivatedColor" format="color" />
|
||||||
|
<attr name="switchBarRestrictionIcon" format="reference" />
|
||||||
|
|
||||||
<attr name="preferenceBackgroundColor" format="color" />
|
<attr name="preferenceBackgroundColor" format="color" />
|
||||||
|
|
||||||
|
@@ -267,6 +267,8 @@
|
|||||||
|
|
||||||
<!-- Restricted icon in switch bar -->
|
<!-- Restricted icon in switch bar -->
|
||||||
<dimen name="restricted_icon_margin_end">16dp</dimen>
|
<dimen name="restricted_icon_margin_end">16dp</dimen>
|
||||||
|
<!-- Restricted icon size in switch bar -->
|
||||||
|
<dimen name="restricted_icon_size">@*android:dimen/config_restricted_icon_size</dimen>
|
||||||
|
|
||||||
<!-- Display Size and Font Size preview screen -->
|
<!-- Display Size and Font Size preview screen -->
|
||||||
<dimen name="preview_pager_padding">8dp</dimen>
|
<dimen name="preview_pager_padding">8dp</dimen>
|
||||||
|
@@ -85,6 +85,7 @@
|
|||||||
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
|
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
|
||||||
<item name="switchBarBackgroundColor">@color/switch_bar_background</item>
|
<item name="switchBarBackgroundColor">@color/switch_bar_background</item>
|
||||||
<item name="switchBarBackgroundActivatedColor">?android:attr/colorAccent</item>
|
<item name="switchBarBackgroundActivatedColor">?android:attr/colorAccent</item>
|
||||||
|
<item name="switchBarRestrictionIcon">@*android:drawable/ic_info</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.SwitchBar.Switch" parent="@android:style/Widget.Material.CompoundButton.Switch">
|
<style name="Widget.SwitchBar.Switch" parent="@android:style/Widget.Material.CompoundButton.Switch">
|
||||||
|
@@ -21,6 +21,7 @@ import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
@@ -32,6 +33,7 @@ import android.view.TouchDelegate;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -64,14 +66,15 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
|||||||
R.attr.switchBarMarginStart,
|
R.attr.switchBarMarginStart,
|
||||||
R.attr.switchBarMarginEnd,
|
R.attr.switchBarMarginEnd,
|
||||||
R.attr.switchBarBackgroundColor,
|
R.attr.switchBarBackgroundColor,
|
||||||
R.attr.switchBarBackgroundActivatedColor};
|
R.attr.switchBarBackgroundActivatedColor,
|
||||||
|
R.attr.switchBarRestrictionIcon};
|
||||||
|
|
||||||
private final List<OnSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
|
private final List<OnSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
|
||||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||||
private final TextAppearanceSpan mSummarySpan;
|
private final TextAppearanceSpan mSummarySpan;
|
||||||
|
|
||||||
private ToggleSwitch mSwitch;
|
private ToggleSwitch mSwitch;
|
||||||
private View mRestrictedIcon;
|
private ImageView mRestrictedIcon;
|
||||||
private TextView mTextView;
|
private TextView mTextView;
|
||||||
private String mLabel;
|
private String mLabel;
|
||||||
private String mSummary;
|
private String mSummary;
|
||||||
@@ -108,10 +111,11 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
|||||||
LayoutInflater.from(context).inflate(R.layout.switch_bar, this);
|
LayoutInflater.from(context).inflate(R.layout.switch_bar, this);
|
||||||
|
|
||||||
final TypedArray a = context.obtainStyledAttributes(attrs, XML_ATTRIBUTES);
|
final TypedArray a = context.obtainStyledAttributes(attrs, XML_ATTRIBUTES);
|
||||||
int switchBarMarginStart = (int) a.getDimension(0, 0);
|
final int switchBarMarginStart = (int) a.getDimension(0, 0);
|
||||||
int switchBarMarginEnd = (int) a.getDimension(1, 0);
|
final int switchBarMarginEnd = (int) a.getDimension(1, 0);
|
||||||
mBackgroundColor = a.getColor(2, 0);
|
mBackgroundColor = a.getColor(2, 0);
|
||||||
mBackgroundActivatedColor = a.getColor(3, 0);
|
mBackgroundActivatedColor = a.getColor(3, 0);
|
||||||
|
final Drawable restrictedIconDrawable = a.getDrawable(4);
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
mTextView = findViewById(R.id.switch_text);
|
mTextView = findViewById(R.id.switch_text);
|
||||||
@@ -134,14 +138,15 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
|||||||
(switchView, isChecked) -> setTextViewLabelAndBackground(isChecked));
|
(switchView, isChecked) -> setTextViewLabelAndBackground(isChecked));
|
||||||
|
|
||||||
mRestrictedIcon = findViewById(R.id.restricted_icon);
|
mRestrictedIcon = findViewById(R.id.restricted_icon);
|
||||||
|
mRestrictedIcon.setImageDrawable(restrictedIconDrawable);
|
||||||
mRestrictedIcon.setOnClickListener(new View.OnClickListener() {
|
mRestrictedIcon.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (mDisabledByAdmin) {
|
if (mDisabledByAdmin) {
|
||||||
mMetricsFeatureProvider.count(mContext,
|
mMetricsFeatureProvider.count(mContext,
|
||||||
mMetricsTag + "/switch_bar|restricted", 1);
|
mMetricsTag + "/switch_bar|restricted", 1);
|
||||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(context,
|
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(context,
|
||||||
mEnforcedAdmin);
|
mEnforcedAdmin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -235,7 +240,7 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
|||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
}
|
}
|
||||||
setTouchDelegate(new TouchDelegate(new Rect(0, 0, getWidth(), getHeight()),
|
setTouchDelegate(new TouchDelegate(new Rect(0, 0, getWidth(), getHeight()),
|
||||||
getDelegatingView()));
|
getDelegatingView()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ToggleSwitch getSwitch() {
|
public final ToggleSwitch getSwitch() {
|
||||||
@@ -249,7 +254,7 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
|||||||
// Make the entire bar work as a switch
|
// Make the entire bar work as a switch
|
||||||
post(() -> setTouchDelegate(
|
post(() -> setTouchDelegate(
|
||||||
new TouchDelegate(new Rect(0, 0, getWidth(), getHeight()),
|
new TouchDelegate(new Rect(0, 0, getWidth(), getHeight()),
|
||||||
getDelegatingView())));
|
getDelegatingView())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +269,7 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
|
|||||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||||
if ((w > 0) && (h > 0)) {
|
if ((w > 0) && (h > 0)) {
|
||||||
setTouchDelegate(new TouchDelegate(new Rect(0, 0, w, h),
|
setTouchDelegate(new TouchDelegate(new Rect(0, 0, w, h),
|
||||||
getDelegatingView()));
|
getDelegatingView()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,4 +21,8 @@
|
|||||||
<bool name="config_show_connectivity_monitor">true</bool>
|
<bool name="config_show_connectivity_monitor">true</bool>
|
||||||
<bool name="config_display_recent_apps">true</bool>
|
<bool name="config_display_recent_apps">true</bool>
|
||||||
<bool name="config_wifi_support_connected_mac_randomization">true</bool>
|
<bool name="config_wifi_support_connected_mac_randomization">true</bool>
|
||||||
|
|
||||||
|
<!-- Fake dimen value for restricted icon size - needed to get around Robolectric
|
||||||
|
issue loading framework hidden resources -->
|
||||||
|
<dimen name="restricted_icon_size">24dp</dimen>
|
||||||
</resources>
|
</resources>
|
@@ -16,4 +16,14 @@
|
|||||||
<item name="preferenceTheme">@style/PreferenceTheme</item>
|
<item name="preferenceTheme">@style/PreferenceTheme</item>
|
||||||
<item name="android:windowLightStatusBar">true</item>
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="ThemeOverlay.SwitchBar.Settings" parent="@android:style/ThemeOverlay.Material.ActionBar">
|
||||||
|
<item name="android:textColorPrimary">@android:color/white</item>
|
||||||
|
<item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
|
||||||
|
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
|
||||||
|
<item name="switchBarBackgroundColor">@color/switch_bar_background</item>
|
||||||
|
<item name="switchBarBackgroundActivatedColor">?android:attr/colorAccent</item>
|
||||||
|
<item name="switchBarRestrictionIcon">@drawable/ic_help</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -77,6 +77,8 @@ public class SettingsRobolectricTestRunner extends RobolectricTestRunner {
|
|||||||
Fs.fromURL(new URL("file:frameworks/base/packages/SettingsLib/res")), null));
|
Fs.fromURL(new URL("file:frameworks/base/packages/SettingsLib/res")), null));
|
||||||
paths.add(new ResourcePath(null,
|
paths.add(new ResourcePath(null,
|
||||||
Fs.fromURL(new URL("file:frameworks/base/packages/SettingsLib/HelpUtils/res/")), null));
|
Fs.fromURL(new URL("file:frameworks/base/packages/SettingsLib/HelpUtils/res/")), null));
|
||||||
|
paths.add(new ResourcePath(null,
|
||||||
|
Fs.fromURL(new URL("file:frameworks/base/packages/SettingsLib/RestrictedLockUtils/res/")), null));
|
||||||
paths.add(new ResourcePath(null,
|
paths.add(new ResourcePath(null,
|
||||||
Fs.fromURL(new URL("file:frameworks/base/core/res/res")), null));
|
Fs.fromURL(new URL("file:frameworks/base/core/res/res")), null));
|
||||||
paths.add(new ResourcePath(null,
|
paths.add(new ResourcePath(null,
|
||||||
|
Reference in New Issue
Block a user