Add Emergency Info preference to user settings
Bug: 26831671 Change-Id: I345fc9b9a54991de35c657e05cf3f08f21445f4c
This commit is contained in:
@@ -5305,6 +5305,10 @@
|
|||||||
<string name="user_enable_calling_and_sms_confirm_title">Turn on phone calls & SMS?</string>
|
<string name="user_enable_calling_and_sms_confirm_title">Turn on phone calls & SMS?</string>
|
||||||
<!-- Message for confirmation of turning on calls and SMS [CHAR LIMIT=none] -->
|
<!-- Message for confirmation of turning on calls and SMS [CHAR LIMIT=none] -->
|
||||||
<string name="user_enable_calling_and_sms_confirm_message">Call and SMS history will be shared with this user.</string>
|
<string name="user_enable_calling_and_sms_confirm_message">Call and SMS history will be shared with this user.</string>
|
||||||
|
<!-- Title for the emergency info preference [CHAR LIMIT=40] -->
|
||||||
|
<string name="emergency_info_title">Emergency information</string>
|
||||||
|
<!-- Description of the emergency info preference [CHAR LIMIT=80] -->
|
||||||
|
<string name="emergency_info_subtitle">Accessible through lock screen in the emergency dialer</string>
|
||||||
|
|
||||||
<!-- Application Restrictions screen title [CHAR LIMIT=45] -->
|
<!-- Application Restrictions screen title [CHAR LIMIT=45] -->
|
||||||
<string name="application_restrictions">Allow apps and content</string>
|
<string name="application_restrictions">Allow apps and content</string>
|
||||||
|
@@ -35,5 +35,9 @@
|
|||||||
android:key="add_users_when_locked"
|
android:key="add_users_when_locked"
|
||||||
android:title="@string/user_add_on_lockscreen_menu"
|
android:title="@string/user_add_on_lockscreen_menu"
|
||||||
android:summary="@string/user_add_on_lockscreen_menu_summary" />
|
android:summary="@string/user_add_on_lockscreen_menu_summary" />
|
||||||
|
<Preference
|
||||||
|
android:key="emergency_info"
|
||||||
|
android:title="@string/emergency_info_title"
|
||||||
|
android:summary="@string/emergency_info_subtitle"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -27,6 +27,7 @@ import android.content.DialogInterface;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@@ -42,6 +43,7 @@ import android.provider.Settings;
|
|||||||
import android.support.v14.preference.SwitchPreference;
|
import android.support.v14.preference.SwitchPreference;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
||||||
|
import android.support.v7.preference.PreferenceCategory;
|
||||||
import android.support.v7.preference.PreferenceGroup;
|
import android.support.v7.preference.PreferenceGroup;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -101,6 +103,10 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
private static final String KEY_USER_LIST = "user_list";
|
private static final String KEY_USER_LIST = "user_list";
|
||||||
private static final String KEY_USER_ME = "user_me";
|
private static final String KEY_USER_ME = "user_me";
|
||||||
private static final String KEY_ADD_USER = "user_add";
|
private static final String KEY_ADD_USER = "user_add";
|
||||||
|
private static final String KEY_EMERGENCY_INFO = "emergency_info";
|
||||||
|
private static final String KEY_LOCK_SCREEN_SETTINGS = "lock_screen_settings";
|
||||||
|
|
||||||
|
private static final String ACTION_EDIT_EMERGENCY_INFO = "android.settings.EDIT_EMERGENGY_INFO";
|
||||||
|
|
||||||
private static final int MENU_REMOVE_USER = Menu.FIRST;
|
private static final int MENU_REMOVE_USER = Menu.FIRST;
|
||||||
|
|
||||||
@@ -134,6 +140,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
private DimmableIconPreference mAddUser;
|
private DimmableIconPreference mAddUser;
|
||||||
private PreferenceGroup mLockScreenSettings;
|
private PreferenceGroup mLockScreenSettings;
|
||||||
private RestrictedSwitchPreference mAddUserWhenLocked;
|
private RestrictedSwitchPreference mAddUserWhenLocked;
|
||||||
|
private Preference mEmergencyInfoPreference;
|
||||||
private int mRemovingUserId = -1;
|
private int mRemovingUserId = -1;
|
||||||
private int mAddedUserId = 0;
|
private int mAddedUserId = 0;
|
||||||
private boolean mAddingUser;
|
private boolean mAddingUser;
|
||||||
@@ -229,6 +236,15 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
mLockScreenSettings = (PreferenceGroup) findPreference("lock_screen_settings");
|
mLockScreenSettings = (PreferenceGroup) findPreference("lock_screen_settings");
|
||||||
mAddUserWhenLocked = (RestrictedSwitchPreference) findPreference("add_users_when_locked");
|
mAddUserWhenLocked = (RestrictedSwitchPreference) findPreference("add_users_when_locked");
|
||||||
|
mEmergencyInfoPreference = findPreference(KEY_EMERGENCY_INFO);
|
||||||
|
if(emergencyInfoActivityPresent()) {
|
||||||
|
mEmergencyInfoPreference.setOnPreferenceClickListener(this);
|
||||||
|
} else {
|
||||||
|
// Remove this view if the emergency info package is not found.
|
||||||
|
PreferenceCategory lockScreenSettingsCategory =
|
||||||
|
(PreferenceCategory) findPreference(KEY_LOCK_SCREEN_SETTINGS);
|
||||||
|
lockScreenSettingsCategory.removePreference(mEmergencyInfoPreference);
|
||||||
|
}
|
||||||
loadProfile();
|
loadProfile();
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
IntentFilter filter = new IntentFilter(Intent.ACTION_USER_REMOVED);
|
IntentFilter filter = new IntentFilter(Intent.ACTION_USER_REMOVED);
|
||||||
@@ -598,6 +614,15 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean emergencyInfoActivityPresent() {
|
||||||
|
Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO).setPackage("com.android.emergency");
|
||||||
|
List<ResolveInfo> infos = getContext().getPackageManager().queryIntentActivities(intent, 0);
|
||||||
|
if (infos == null || infos.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void removeUserNow() {
|
private void removeUserNow() {
|
||||||
if (mRemovingUserId == UserHandle.myUserId()) {
|
if (mRemovingUserId == UserHandle.myUserId()) {
|
||||||
removeThisUser();
|
removeThisUser();
|
||||||
@@ -917,6 +942,9 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
} else {
|
} else {
|
||||||
onAddUserClicked(USER_TYPE_USER);
|
onAddUserClicked(USER_TYPE_USER);
|
||||||
}
|
}
|
||||||
|
} else if (pref == mEmergencyInfoPreference) {
|
||||||
|
Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO);
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user