Fix the color of dot wrongly in device admin page
In this cl, we migrate origin files/method from framework into settings app. So, we can control layout and drawble without impacting other app. And we only remove to set a tint color in app_permission_item.xml. Currently, it won't tint color for dot now. Test: See the screen and dot's color is correct. Fix: 188188444 Change-Id: I18054b47ba07e7864e7c238f2bec5fbe1d3feeea
This commit is contained in:
24
res/drawable/ic_text_dot.xml
Normal file
24
res/drawable/ic_text_dot.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<inset
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:inset="10dp">
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="?android:attr/textColorSecondary" />
|
||||
<size android:width="4dp" android:height="4dp" />
|
||||
</shape>
|
||||
</inset>
|
51
res/layout/app_permission_item.xml
Normal file
51
res/layout/app_permission_item.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/perm_icon"
|
||||
android:layout_width="24dip"
|
||||
android:layout_height="24dip"
|
||||
android:layout_alignParentStart="true"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/permission_group"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textStyle="bold"
|
||||
android:paddingStart="6dip"
|
||||
android:layout_toEndOf="@id/perm_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/permission_list"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_marginTop="-4dip"
|
||||
android:paddingBottom="8dip"
|
||||
android:paddingStart="6dip"
|
||||
android:layout_below="@id/permission_group"
|
||||
android:layout_toEndOf="@id/perm_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</RelativeLayout>
|
@@ -38,6 +38,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -52,11 +53,11 @@ import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AppSecurityPermissions;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -134,6 +135,8 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
|
||||
|
||||
boolean mIsCalledFromSupportDialog = false;
|
||||
|
||||
private LayoutInflater mLayoutInflaternflater;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -142,6 +145,7 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
|
||||
|
||||
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
mAppOps = (AppOpsManager)getSystemService(Context.APP_OPS_SERVICE);
|
||||
mLayoutInflaternflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
PackageManager packageManager = getPackageManager();
|
||||
|
||||
if ((getIntent().getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
|
||||
@@ -735,14 +739,36 @@ public class DeviceAdminAdd extends CollapsingToolbarBaseActivity {
|
||||
for (DeviceAdminInfo.PolicyInfo pi : mDeviceAdmin.getUsedPolicies()) {
|
||||
int descriptionId = isAdminUser ? pi.description : pi.descriptionForSecondaryUsers;
|
||||
int labelId = isAdminUser ? pi.label : pi.labelForSecondaryUsers;
|
||||
View view = AppSecurityPermissions.getPermissionItemView(this, getText(labelId),
|
||||
showDescription ? getText(descriptionId) : "", true);
|
||||
View view = getPermissionItemView(getText(labelId),
|
||||
showDescription ? getText(descriptionId) : "");
|
||||
mAdminPolicies.addView(view);
|
||||
}
|
||||
mAdminPoliciesInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility to retrieve a view displaying a single permission. This provides
|
||||
* the UI layout for permissions.
|
||||
*/
|
||||
private View getPermissionItemView(CharSequence grpName, CharSequence description) {
|
||||
Drawable icon = this.getDrawable(com.android.internal.R.drawable.ic_text_dot);
|
||||
View permView = mLayoutInflaternflater.inflate(R.layout.app_permission_item, null);
|
||||
TextView permGrpView = permView.findViewById(R.id.permission_group);
|
||||
TextView permDescView = permView.findViewById(R.id.permission_list);
|
||||
ImageView imgView = (ImageView) permView.findViewById(R.id.perm_icon);
|
||||
|
||||
imgView.setImageDrawable(icon);
|
||||
if (grpName != null) {
|
||||
permGrpView.setText(grpName);
|
||||
permDescView.setText(description);
|
||||
} else {
|
||||
permGrpView.setText(description);
|
||||
permDescView.setVisibility(View.GONE);
|
||||
}
|
||||
return permView;
|
||||
}
|
||||
|
||||
void toggleMessageEllipsis(View v) {
|
||||
TextView tv = (TextView) v;
|
||||
|
||||
|
Reference in New Issue
Block a user