Make Settings use system-api restricted icon.
Test: Browsed around settings
Bug: 110953302
Change-Id: I1b19be721719ed8946cb558b93119b1b0e173794
diff --git a/res/layout/admin_support_details_dialog.xml b/res/layout/admin_support_details_dialog.xml
index 7de91d0..8c33b1a 100644
--- a/res/layout/admin_support_details_dialog.xml
+++ b/res/layout/admin_support_details_dialog.xml
@@ -27,7 +27,8 @@
<ImageView android:id="@+id/admin_support_icon"
android:layout_width="@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:contentDescription="@null" />
<TextView android:id="@+id/admin_support_dialog_title"
diff --git a/res/layout/lockscreen_remote_input.xml b/res/layout/lockscreen_remote_input.xml
index 1c565a3..68b35f9 100644
--- a/res/layout/lockscreen_remote_input.xml
+++ b/res/layout/lockscreen_remote_input.xml
@@ -36,10 +36,11 @@
<ImageView
android:id="@+id/restricted_lock_icon_remote_input"
- android:layout_width="@dimen/restricted_icon_size"
- android:layout_height="@dimen/restricted_icon_size"
- android:src="@drawable/ic_info"
+ android:layout_width="@*android:dimen/config_restricted_icon_size"
+ android:layout_height="@*android:dimen/config_restricted_icon_size"
+ android:tint="?android:attr/colorAccent"
+ android:src="@*android:drawable/ic_info"
android:layout_marginEnd="?android:attr/dialogPreferredPadding"
android:layout_gravity="center_vertical"
android:scaleType="centerInside" />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/res/layout/printer_dropdown_item.xml b/res/layout/printer_dropdown_item.xml
index 1036e24..fd581bb 100644
--- a/res/layout/printer_dropdown_item.xml
+++ b/res/layout/printer_dropdown_item.xml
@@ -77,7 +77,7 @@
android:layout_gravity="center_vertical"
android:paddingLeft="16dip"
android:contentDescription="@string/printer_info_desc"
- android:src="@drawable/ic_info"
+ android:src="@*android:drawable/ic_info"
android:tint="?android:attr/colorControlNormal"
android:tintMode="src_in" />
diff --git a/res/layout/restricted_dialog_singlechoice.xml b/res/layout/restricted_dialog_singlechoice.xml
index 3daedc7..48f62ce 100644
--- a/res/layout/restricted_dialog_singlechoice.xml
+++ b/res/layout/restricted_dialog_singlechoice.xml
@@ -37,11 +37,12 @@
android:ellipsize="marquee" />
<ImageView
android:id="@+id/restricted_lock_icon"
- android:layout_width="@dimen/restricted_icon_size"
- android:layout_height="@dimen/restricted_icon_size"
- android:src="@drawable/ic_info"
+ android:layout_width="@*android:dimen/config_restricted_icon_size"
+ android:layout_height="@*android:dimen/config_restricted_icon_size"
+ android:tint="?android:attr/colorAccent"
+ android:src="@*android:drawable/ic_info"
android:layout_marginLeft="@dimen/restricted_icon_padding"
android:baselineAlignBottom="true"
android:scaleType="centerInside"
android:visibility="gone" />
-</com.android.settings.CheckableLinearLayout>
\ No newline at end of file
+</com.android.settings.CheckableLinearLayout>
diff --git a/res/layout/restricted_popup_menu_item.xml b/res/layout/restricted_popup_menu_item.xml
index 78a09ef..9f6da73 100644
--- a/res/layout/restricted_popup_menu_item.xml
+++ b/res/layout/restricted_popup_menu_item.xml
@@ -34,10 +34,11 @@
android:layout_alignParentLeft="true" />
<ImageView
android:id="@+id/restricted_icon"
- android:layout_width="@dimen/restricted_icon_size"
- android:layout_height="@dimen/restricted_icon_size"
+ android:layout_width="@*android:dimen/config_restricted_icon_size"
+ android:layout_height="@*android:dimen/config_restricted_icon_size"
android:scaleType="centerInside"
- android:src="@drawable/ic_info"
+ android:tint="?android:attr/colorAccent"
+ android:src="@*android:drawable/ic_info"
android:layout_alignParentRight="true"
android:visibility="gone" />
-</RelativeLayout>
\ No newline at end of file
+</RelativeLayout>
diff --git a/res/layout/restricted_radio_with_summary.xml b/res/layout/restricted_radio_with_summary.xml
index 55f158c..4808460 100644
--- a/res/layout/restricted_radio_with_summary.xml
+++ b/res/layout/restricted_radio_with_summary.xml
@@ -41,10 +41,11 @@
android:ellipsize="marquee" />
<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="match_parent"
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:visibility="gone" />
</com.android.settings.CheckableLinearLayout>
@@ -59,4 +60,4 @@
android:textColor="?android:attr/textColorSecondary"
android:maxLines="10" />
-</com.android.settings.CheckableLinearLayout>
\ No newline at end of file
+</com.android.settings.CheckableLinearLayout>
diff --git a/res/layout/spinner_dropdown_restricted_item.xml b/res/layout/spinner_dropdown_restricted_item.xml
index 823b430..be85966 100644
--- a/res/layout/spinner_dropdown_restricted_item.xml
+++ b/res/layout/spinner_dropdown_restricted_item.xml
@@ -26,11 +26,12 @@
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:ellipsize="marquee" />
<ImageView android:id="@+id/restricted_icon"
- android:layout_width="@dimen/restricted_icon_size"
- android:layout_height="@dimen/restricted_icon_size"
- android:src="@drawable/ic_info"
+ android:layout_width="@*android:dimen/config_restricted_icon_size"
+ android:layout_height="@*android:dimen/config_restricted_icon_size"
+ android:tint="?android:attr/colorAccent"
+ android:src="@*android:drawable/ic_info"
android:baselineAlignBottom="true"
android:layout_marginEnd="@dimen/restricted_icon_padding"
android:gravity="end|center_vertical"
android:visibility="gone" />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/res/layout/switch_bar.xml b/res/layout/switch_bar.xml
index a172051..e305f9d 100644
--- a/res/layout/switch_bar.xml
+++ b/res/layout/switch_bar.xml
@@ -29,24 +29,23 @@
android:ellipsize="end"
android:textAppearance="@style/TextAppearance.Switch"
android:textColor="?android:attr/textColorPrimary"
- android:textAlignment="viewStart" />
+ android:textAlignment="viewStart"/>
<ImageView
android:id="@+id/restricted_icon"
android:layout_width="@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:layout_gravity="center_vertical"
- android:layout_marginEnd="@dimen/restricted_icon_margin_end"
- android:visibility="gone" />
+ android:layout_marginEnd="@dimen/restricted_icon_margin_end"/>
<com.android.settings.widget.ToggleSwitch
android:id="@+id/switch_widget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:theme="@style/Widget.SwitchBar.Switch" />
+ android:theme="@style/Widget.SwitchBar.Switch"/>
</merge>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index a4ce9f0..e729126 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -101,6 +101,7 @@
<attr name="switchBarMarginEnd" format="dimension" />
<attr name="switchBarBackgroundColor" format="color" />
<attr name="switchBarBackgroundActivatedColor" format="color" />
+ <attr name="switchBarRestrictionIcon" format="reference" />
<attr name="preferenceBackgroundColor" format="color" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 16d9f96..70672ca 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -267,6 +267,8 @@
<!-- Restricted icon in switch bar -->
<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 -->
<dimen name="preview_pager_padding">8dp</dimen>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 4bd6f52..b1afe63 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -85,6 +85,7 @@
<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">@*android:drawable/ic_info</item>
</style>
<style name="Widget.SwitchBar.Switch" parent="@android:style/Widget.Material.CompoundButton.Switch">
diff --git a/src/com/android/settings/widget/SwitchBar.java b/src/com/android/settings/widget/SwitchBar.java
index 52a3288..8afba40 100644
--- a/src/com/android/settings/widget/SwitchBar.java
+++ b/src/com/android/settings/widget/SwitchBar.java
@@ -21,6 +21,7 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.SpannableStringBuilder;
@@ -32,6 +33,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;
@@ -64,14 +66,15 @@
R.attr.switchBarMarginStart,
R.attr.switchBarMarginEnd,
R.attr.switchBarBackgroundColor,
- R.attr.switchBarBackgroundActivatedColor};
+ R.attr.switchBarBackgroundActivatedColor,
+ R.attr.switchBarRestrictionIcon};
private final List<OnSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
private final MetricsFeatureProvider mMetricsFeatureProvider;
private final TextAppearanceSpan mSummarySpan;
private ToggleSwitch mSwitch;
- private View mRestrictedIcon;
+ private ImageView mRestrictedIcon;
private TextView mTextView;
private String mLabel;
private String mSummary;
@@ -108,10 +111,11 @@
LayoutInflater.from(context).inflate(R.layout.switch_bar, this);
final TypedArray a = context.obtainStyledAttributes(attrs, XML_ATTRIBUTES);
- int switchBarMarginStart = (int) a.getDimension(0, 0);
- int switchBarMarginEnd = (int) a.getDimension(1, 0);
+ final int switchBarMarginStart = (int) a.getDimension(0, 0);
+ final int switchBarMarginEnd = (int) a.getDimension(1, 0);
mBackgroundColor = a.getColor(2, 0);
mBackgroundActivatedColor = a.getColor(3, 0);
+ final Drawable restrictedIconDrawable = a.getDrawable(4);
a.recycle();
mTextView = findViewById(R.id.switch_text);
@@ -134,14 +138,15 @@
(switchView, isChecked) -> setTextViewLabelAndBackground(isChecked));
mRestrictedIcon = findViewById(R.id.restricted_icon);
+ mRestrictedIcon.setImageDrawable(restrictedIconDrawable);
mRestrictedIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mDisabledByAdmin) {
mMetricsFeatureProvider.count(mContext,
- mMetricsTag + "/switch_bar|restricted", 1);
+ mMetricsTag + "/switch_bar|restricted", 1);
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(context,
- mEnforcedAdmin);
+ mEnforcedAdmin);
}
}
});
@@ -235,7 +240,7 @@
setEnabled(true);
}
setTouchDelegate(new TouchDelegate(new Rect(0, 0, getWidth(), getHeight()),
- getDelegatingView()));
+ getDelegatingView()));
}
public final ToggleSwitch getSwitch() {
@@ -249,7 +254,7 @@
// Make the entire bar work as a switch
post(() -> setTouchDelegate(
new TouchDelegate(new Rect(0, 0, getWidth(), getHeight()),
- getDelegatingView())));
+ getDelegatingView())));
}
}
@@ -264,7 +269,7 @@
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
if ((w > 0) && (h > 0)) {
setTouchDelegate(new TouchDelegate(new Rect(0, 0, w, h),
- getDelegatingView()));
+ getDelegatingView()));
}
}
diff --git a/tests/robotests/res/values/config.xml b/tests/robotests/res/values/config.xml
index bbf2520..1252ece 100644
--- a/tests/robotests/res/values/config.xml
+++ b/tests/robotests/res/values/config.xml
@@ -21,4 +21,8 @@
<bool name="config_show_connectivity_monitor">true</bool>
<bool name="config_display_recent_apps">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>
\ No newline at end of file
diff --git a/tests/robotests/res/values/themes.xml b/tests/robotests/res/values/themes.xml
index d3ba69f..7bfbe10 100644
--- a/tests/robotests/res/values/themes.xml
+++ b/tests/robotests/res/values/themes.xml
@@ -16,4 +16,14 @@
<item name="preferenceTheme">@style/PreferenceTheme</item>
<item name="android:windowLightStatusBar">true</item>
</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>
diff --git a/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java b/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java
index 87f0a37..14d5c75 100644
--- a/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java
+++ b/tests/robotests/src/com/android/settings/testutils/SettingsRobolectricTestRunner.java
@@ -78,6 +78,8 @@
paths.add(new ResourcePath(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,
Fs.fromURL(new URL("file:frameworks/base/core/res/res")), null));
paths.add(new ResourcePath(null,
Fs.fromURL(new URL("file:frameworks/opt/setupwizard/library/main/res")), null));