Work on the device admin settings UI.
Improve the look of the UI, and add the confirmation screen for enabling an administrator. This uses the new framework APIs to show its description and policies it will control.
This commit is contained in:
@@ -402,17 +402,28 @@
|
|||||||
|
|
||||||
<activity android:name="DeviceAdminSettings"
|
<activity android:name="DeviceAdminSettings"
|
||||||
android:label="@string/device_admin_settings_title"
|
android:label="@string/device_admin_settings_title"
|
||||||
|
android:theme="@style/TallTitleBarTheme"
|
||||||
android:clearTaskOnLaunch="true"
|
android:clearTaskOnLaunch="true"
|
||||||
>
|
>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<action android:name="android.app.action.ADD_DEVICE_ADMIN" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
||||||
<category android:name="com.android.settings.SHORTCUT" />
|
<category android:name="com.android.settings.SHORTCUT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name="DeviceAdminAdd"
|
||||||
|
android:label="@string/device_admin_add_title"
|
||||||
|
android:theme="@style/TallTitleBarTheme"
|
||||||
|
android:clearTaskOnLaunch="true"
|
||||||
|
>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.app.action.ADD_DEVICE_ADMIN" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name="IccLockSettings" android:label="@string/sim_lock_settings"
|
<activity android:name="IccLockSettings" android:label="@string/sim_lock_settings"
|
||||||
android:process="com.android.phone">
|
android:process="com.android.phone">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
105
res/layout/device_admin_add.xml
Normal file
105
res/layout/device_admin_add.xml
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2010 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/active_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="@*android:drawable/title_bar_medium">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="@string/add_device_admin_msg"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:shadowColor="?android:attr/colorBackground"
|
||||||
|
android:shadowRadius="2" />
|
||||||
|
</LinearLayout>
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<ImageView android:id="@+id/active_icon"
|
||||||
|
android:layout_width="@android:dimen/app_icon_size"
|
||||||
|
android:layout_height="@android:dimen/app_icon_size"
|
||||||
|
android:layout_marginLeft="5dip"
|
||||||
|
android:layout_marginRight="11dip"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:scaleType="fitCenter"/>
|
||||||
|
<TextView android:id="@+id/active_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginBottom="2dip"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee" />
|
||||||
|
</LinearLayout>
|
||||||
|
<TextView android:id="@+id/active_description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:padding="10dip" />
|
||||||
|
<TextView android:id="@+id/active_warning"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="10dip" />
|
||||||
|
<LinearLayout android:id="@+id/admin_policies"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="16dip"
|
||||||
|
android:paddingRight="12dip" />
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
<LinearLayout style="@android:style/ButtonBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<View
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
<Button android:id="@+id/add_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/add_device_admin" />
|
||||||
|
<View
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
@@ -24,14 +24,21 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="20dip"
|
android:orientation="horizontal"
|
||||||
android:paddingTop="5dip"
|
android:background="@*android:drawable/title_bar_medium">
|
||||||
android:text="@string/active_device_admin_msg"
|
<TextView
|
||||||
android:gravity="center"
|
android:layout_width="match_parent"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
android:layout_height="match_parent"
|
||||||
|
android:text="@string/active_device_admin_msg"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:shadowColor="?android:attr/colorBackground"
|
||||||
|
android:shadowRadius="2" />
|
||||||
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -56,13 +63,27 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<TextView android:id="@+id/active_description"
|
<TextView android:id="@+id/active_description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
<Button android:id="@+id/remove_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android_layout_gravity="center_vertical|east"
|
android:layout_weight="1"
|
||||||
android:text="@string/remove_device_admin"
|
android:padding="10dip" />
|
||||||
/>
|
<LinearLayout style="@android:style/ButtonBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
<View
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
<Button android:id="@+id/remove_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/remove_device_admin" />
|
||||||
|
<View
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -71,17 +92,26 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="20dip"
|
android:orientation="horizontal"
|
||||||
android:paddingTop="5dip"
|
android:background="@*android:drawable/title_bar_medium">
|
||||||
android:text="@string/select_device_admin_msg"
|
<TextView
|
||||||
android:gravity="center"
|
android:layout_width="match_parent"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
android:layout_height="match_parent"
|
||||||
|
android:text="@string/select_device_admin_msg"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:shadowColor="?android:attr/colorBackground"
|
||||||
|
android:shadowRadius="2" />
|
||||||
|
</LinearLayout>
|
||||||
<ListView android:id="@android:id/list"
|
<ListView android:id="@android:id/list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:paddingTop="10dip"
|
||||||
|
android:paddingBottom="10dip"
|
||||||
android:drawSelectorOnTop="false"
|
android:drawSelectorOnTop="false"
|
||||||
android:fastScrollEnabled="true" />
|
android:fastScrollEnabled="true" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -2349,10 +2349,21 @@ found in the list of installed applications.</string>
|
|||||||
<!-- Label for screen showing the active device policy -->
|
<!-- Label for screen showing the active device policy -->
|
||||||
<string name="active_device_admin_msg">Active device administrator</string>
|
<string name="active_device_admin_msg">Active device administrator</string>
|
||||||
<!-- Label for button to remove the active device admin -->
|
<!-- Label for button to remove the active device admin -->
|
||||||
<string name="remove_device_admin">Remove</string>
|
<string name="remove_device_admin">Deactivate</string>
|
||||||
<!-- Label for screen showing to select device policy -->
|
<!-- Label for screen showing to select device policy -->
|
||||||
<string name="select_device_admin_msg">Select device administrator</string>
|
<string name="select_device_admin_msg">Select device administrator</string>
|
||||||
|
|
||||||
|
<!-- Label for screen showing to add device policy -->
|
||||||
|
<string name="add_device_admin_msg">Activate device administrator</string>
|
||||||
|
<!-- Label for button to set the active device admin -->
|
||||||
|
<string name="add_device_admin">Activate</string>
|
||||||
|
<!-- Device admin add activity title -->
|
||||||
|
<string name="device_admin_add_title">Activate device administrator</string>
|
||||||
|
<!-- Device admin warning message about policies an admin can use -->
|
||||||
|
<string name="device_admin_warning">Activating this administrator will allow
|
||||||
|
the application <xliff:g id="app_name">%1$s</xliff:g> to perform the
|
||||||
|
following operations:</string>
|
||||||
|
|
||||||
<!-- Name to assign to a Network Access Point that was saved without a name -->
|
<!-- Name to assign to a Network Access Point that was saved without a name -->
|
||||||
<string name="untitled_apn">Untitled</string>
|
<string name="untitled_apn">Untitled</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -78,4 +78,8 @@
|
|||||||
<item name="android:textStyle">normal</item>
|
<item name="android:textStyle">normal</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TallTitleBarTheme" parent="android:Theme.NoTitleBar">
|
||||||
|
<item name="android:windowContentOverlay">@null</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
146
src/com/android/settings/DeviceAdminAdd.java
Normal file
146
src/com/android/settings/DeviceAdminAdd.java
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings;
|
||||||
|
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.DeviceAdminInfo;
|
||||||
|
import android.app.DevicePolicyManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AppSecurityPermissions;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class DeviceAdminAdd extends Activity {
|
||||||
|
static final String TAG = "DeviceAdminAdd";
|
||||||
|
|
||||||
|
DevicePolicyManager mDPM;
|
||||||
|
DeviceAdminInfo mDeviceAdmin;
|
||||||
|
|
||||||
|
ImageView mActiveIcon;
|
||||||
|
TextView mActiveName;
|
||||||
|
TextView mActiveDescription;
|
||||||
|
TextView mActiveWarning;
|
||||||
|
ViewGroup mAdminPolicies;
|
||||||
|
|
||||||
|
View mSelectLayout;
|
||||||
|
ArrayList<DeviceAdminInfo> mAvailablePolicies
|
||||||
|
= new ArrayList<DeviceAdminInfo>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle icicle) {
|
||||||
|
super.onCreate(icicle);
|
||||||
|
|
||||||
|
mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
|
DeviceAdminInfo activeAdmin = mDPM.getActiveAdminInfo();
|
||||||
|
|
||||||
|
ComponentName cn = (ComponentName)getIntent().getParcelableExtra(
|
||||||
|
DevicePolicyManager.EXTRA_DEVICE_ADMIN);
|
||||||
|
if (cn == null) {
|
||||||
|
Log.w(TAG, "No component specified in " + getIntent().getAction());
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cn.equals(activeAdmin)) {
|
||||||
|
setResult(Activity.RESULT_OK);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (activeAdmin != null) {
|
||||||
|
Log.w(TAG, "Admin already set, can't do " + getIntent().getAction());
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActivityInfo ai;
|
||||||
|
try {
|
||||||
|
ai = getPackageManager().getReceiverInfo(cn,
|
||||||
|
PackageManager.GET_META_DATA);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
Log.w(TAG, "Unable to retrieve device policy " + cn, e);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResolveInfo ri = new ResolveInfo();
|
||||||
|
ri.activityInfo = ai;
|
||||||
|
try {
|
||||||
|
mDeviceAdmin= new DeviceAdminInfo(this, ri);
|
||||||
|
} catch (XmlPullParserException e) {
|
||||||
|
Log.w(TAG, "Unable to retrieve device policy " + cn, e);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w(TAG, "Unable to retrieve device policy " + cn, e);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setContentView(R.layout.device_admin_add);
|
||||||
|
|
||||||
|
mActiveIcon = (ImageView)findViewById(R.id.active_icon);
|
||||||
|
mActiveName = (TextView)findViewById(R.id.active_name);
|
||||||
|
mActiveDescription = (TextView)findViewById(R.id.active_description);
|
||||||
|
mActiveWarning = (TextView)findViewById(R.id.active_warning);
|
||||||
|
mAdminPolicies = (ViewGroup)findViewById(R.id.admin_policies);
|
||||||
|
findViewById(R.id.add_button).setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
mDPM.setActiveAdmin(mDeviceAdmin.getComponent());
|
||||||
|
setResult(Activity.RESULT_OK);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
updateInterface();
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateInterface() {
|
||||||
|
mActiveIcon.setImageDrawable(mDeviceAdmin.loadIcon(getPackageManager()));
|
||||||
|
mActiveName.setText(mDeviceAdmin.loadLabel(getPackageManager()));
|
||||||
|
try {
|
||||||
|
mActiveDescription.setText(
|
||||||
|
mDeviceAdmin.loadDescription(getPackageManager()));
|
||||||
|
} catch (Resources.NotFoundException e) {
|
||||||
|
}
|
||||||
|
mActiveWarning.setText(getString(R.string.device_admin_warning,
|
||||||
|
mDeviceAdmin.getActivityInfo().applicationInfo.loadLabel(getPackageManager())));
|
||||||
|
ArrayList<DeviceAdminInfo.PolicyInfo> policies = mDeviceAdmin.getUsedPolicies();
|
||||||
|
for (int i=0; i<policies.size(); i++) {
|
||||||
|
DeviceAdminInfo.PolicyInfo pi = policies.get(i);
|
||||||
|
mAdminPolicies.addView(AppSecurityPermissions.getPermissionItemView(
|
||||||
|
this, getText(pi.label), getText(pi.description), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -28,6 +28,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -80,10 +81,7 @@ public class DeviceAdminSettings extends ListActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mSelectLayout = findViewById(R.id.select_layout);
|
mSelectLayout = findViewById(R.id.select_layout);
|
||||||
getListView().setDivider(null);
|
|
||||||
|
|
||||||
updateLayout();
|
|
||||||
|
|
||||||
if (DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN.equals(getIntent().getAction())) {
|
if (DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN.equals(getIntent().getAction())) {
|
||||||
ComponentName cn = (ComponentName)getIntent().getParcelableExtra(
|
ComponentName cn = (ComponentName)getIntent().getParcelableExtra(
|
||||||
DevicePolicyManager.EXTRA_DEVICE_ADMIN);
|
DevicePolicyManager.EXTRA_DEVICE_ADMIN);
|
||||||
@@ -114,12 +112,23 @@ public class DeviceAdminSettings extends ListActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
updateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
void updateLayout() {
|
void updateLayout() {
|
||||||
if (mCurrentAdmin != null) {
|
if (mCurrentAdmin != null) {
|
||||||
mActiveLayout.setVisibility(View.VISIBLE);
|
mActiveLayout.setVisibility(View.VISIBLE);
|
||||||
mSelectLayout.setVisibility(View.GONE);
|
mSelectLayout.setVisibility(View.GONE);
|
||||||
mActiveIcon.setImageDrawable(mCurrentAdmin.loadIcon(getPackageManager()));
|
mActiveIcon.setImageDrawable(mCurrentAdmin.loadIcon(getPackageManager()));
|
||||||
mActiveName.setText(mCurrentAdmin.loadLabel(getPackageManager()));
|
mActiveName.setText(mCurrentAdmin.loadLabel(getPackageManager()));
|
||||||
|
try {
|
||||||
|
mActiveDescription.setText(
|
||||||
|
mCurrentAdmin.loadDescription(getPackageManager()));
|
||||||
|
} catch (Resources.NotFoundException e) {
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mActiveLayout.setVisibility(View.GONE);
|
mActiveLayout.setVisibility(View.GONE);
|
||||||
mSelectLayout.setVisibility(View.VISIBLE);
|
mSelectLayout.setVisibility(View.VISIBLE);
|
||||||
@@ -145,8 +154,9 @@ public class DeviceAdminSettings extends ListActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
DeviceAdminInfo dpi = (DeviceAdminInfo)l.getAdapter().getItem(position);
|
DeviceAdminInfo dpi = (DeviceAdminInfo)l.getAdapter().getItem(position);
|
||||||
mDPM.setActiveAdmin(dpi.getComponent());
|
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
|
||||||
finish();
|
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, dpi.getComponent());
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ViewHolder {
|
static class ViewHolder {
|
||||||
|
Reference in New Issue
Block a user