Merge "Change owner info to be a dialog rather than screen"
This commit is contained in:
@@ -16,70 +16,29 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="20dip"
|
||||||
|
android:paddingEnd="20dip"
|
||||||
|
android:paddingTop="20dip"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:scrollbars="vertical"
|
|
||||||
android:background="@android:color/white">
|
android:background="@android:color/white">
|
||||||
|
|
||||||
<ScrollView
|
<EditText
|
||||||
|
android:id="@+id/owner_info_edit_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:scrollbarStyle="outsideOverlay"
|
android:gravity="top"
|
||||||
android:fillViewport="true">
|
android:hint="@string/owner_info_settings_edit_text_hint"
|
||||||
|
android:maxLength="100"
|
||||||
|
android:inputType="textMultiLine|textCapSentences"
|
||||||
|
/>
|
||||||
|
|
||||||
<LinearLayout
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/owner_info_status"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:orientation="vertical"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
android:gravity="end"
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
/>
|
||||||
<View
|
|
||||||
android:paddingTop="53dip"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dip"
|
|
||||||
android:background="#ff404040"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<EditText android:id="@+id/owner_info_nickname"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="8dip"
|
|
||||||
android:gravity="top"
|
|
||||||
android:hint="@string/user_nickname"
|
|
||||||
android:inputType="textCapWords"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<CheckBox android:id="@+id/show_owner_info_on_lockscreen_checkbox"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="64dip"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:layout_marginTop="8dip"
|
|
||||||
android:text="@string/show_owner_info_on_lockscreen_label"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dip"
|
|
||||||
android:background="#ff404040"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<EditText android:id="@+id/owner_info_edit_text"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="62dip"
|
|
||||||
android:layout_marginTop="40dip"
|
|
||||||
android:gravity="top"
|
|
||||||
android:hint="@string/owner_info_settings_edit_text_hint"
|
|
||||||
android:lines="8"
|
|
||||||
android:maxLines="8"
|
|
||||||
android:inputType="textMultiLine|textCapSentences"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@@ -700,17 +700,17 @@
|
|||||||
<!-- Text shown next to checkbox for showing owner info on LockScreen [CHAR LIMIT=50]-->
|
<!-- Text shown next to checkbox for showing owner info on LockScreen [CHAR LIMIT=50]-->
|
||||||
<string name="show_owner_info_on_lockscreen_label">Show owner info on lock screen</string>
|
<string name="show_owner_info_on_lockscreen_label">Show owner info on lock screen</string>
|
||||||
<!-- Text shown for title of owner info setting [CHAR LIMIT=20]-->
|
<!-- Text shown for title of owner info setting [CHAR LIMIT=20]-->
|
||||||
<string name="owner_info_settings_title">Owner info</string>
|
<string name="owner_info_settings_title">Lock screen message</string>
|
||||||
<!-- Text shown for title of settings checkbox to enable widgets [CHAR LIMIT=20]-->
|
<!-- Text shown for title of settings checkbox to enable widgets [CHAR LIMIT=20]-->
|
||||||
<string name="security_enable_widgets_title">Enable widgets</string>
|
<string name="security_enable_widgets_title">Enable widgets</string>
|
||||||
<!-- Summary for settings checkbox to disable widgets when the setting has been disabled by an installed device admin [CHAR LIMIT=50] -->
|
<!-- Summary for settings checkbox to disable widgets when the setting has been disabled by an installed device admin [CHAR LIMIT=50] -->
|
||||||
<string name="security_enable_widgets_disabled_summary">Disabled by administrator</string>
|
<string name="security_enable_widgets_disabled_summary">Disabled by administrator</string>
|
||||||
<!-- Text shown for summary of owner info setting [CHAR LIMIT=40]-->
|
<!-- Text shown for summary of owner info setting (if none set) [CHAR LIMIT=40]-->
|
||||||
<string name="owner_info_settings_summary"></string>
|
<string name="owner_info_settings_summary">None</string>
|
||||||
|
<!-- Description of how many characters are used in owner info [CHAR LIMIT=40]-->
|
||||||
|
<string name="owner_info_settings_status"><xliff:g id="count" example="90">%1$d</xliff:g> / <xliff:g id="count" example="100">%2$d</xliff:g></string>
|
||||||
<!-- Hint text shown in owner info edit text [CHAR LIMIT=50] -->
|
<!-- Hint text shown in owner info edit text [CHAR LIMIT=50] -->
|
||||||
<string name="owner_info_settings_edit_text_hint">Type text to display on the lock screen</string>
|
<string name="owner_info_settings_edit_text_hint">E.g., Joe\'s Android.</string>
|
||||||
<!-- Text shown next to checkbox for showing user info on LockScreen [CHAR LIMIT=50]-->
|
|
||||||
<string name="show_user_info_on_lockscreen_label">Show user info on lock screen</string>
|
|
||||||
<!-- Text shown for title of user info setting [CHAR LIMIT=20]-->
|
<!-- Text shown for title of user info setting [CHAR LIMIT=20]-->
|
||||||
<string name="user_info_settings_title">User info</string>
|
<string name="user_info_settings_title">User info</string>
|
||||||
<!-- Text shown next to checkbox for showing profile info on LockScreen [CHAR LIMIT=50]-->
|
<!-- Text shown next to checkbox for showing profile info on LockScreen [CHAR LIMIT=50]-->
|
||||||
|
@@ -27,9 +27,8 @@
|
|||||||
android:summary="@string/unlock_set_unlock_mode_none"
|
android:summary="@string/unlock_set_unlock_mode_none"
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
<PreferenceScreen
|
<com.android.settings.SingleLineSummaryPreference
|
||||||
android:key="owner_info_settings"
|
android:key="owner_info_settings"
|
||||||
android:fragment="com.android.settings.OwnerInfoSettings"
|
|
||||||
android:title="@string/owner_info_settings_title"
|
android:title="@string/owner_info_settings_title"
|
||||||
android:summary="@string/owner_info_settings_summary"/>
|
android:summary="@string/owner_info_settings_summary"/>
|
||||||
|
|
||||||
|
@@ -29,9 +29,8 @@
|
|||||||
settings:keywords="@string/keywords_lockscreen"
|
settings:keywords="@string/keywords_lockscreen"
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
<PreferenceScreen
|
<com.android.settings.SingleLineSummaryPreference
|
||||||
android:key="owner_info_settings"
|
android:key="owner_info_settings"
|
||||||
android:fragment="com.android.settings.OwnerInfoSettings"
|
|
||||||
android:title="@string/owner_info_settings_title"
|
android:title="@string/owner_info_settings_title"
|
||||||
android:summary="@string/owner_info_settings_summary"/>
|
android:summary="@string/owner_info_settings_summary"/>
|
||||||
|
|
||||||
|
@@ -41,9 +41,8 @@
|
|||||||
android:key="power_button_instantly_locks"
|
android:key="power_button_instantly_locks"
|
||||||
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
|
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
|
||||||
|
|
||||||
<PreferenceScreen
|
<com.android.settings.SingleLineSummaryPreference
|
||||||
android:key="owner_info_settings"
|
android:key="owner_info_settings"
|
||||||
android:fragment="com.android.settings.OwnerInfoSettings"
|
|
||||||
android:title="@string/owner_info_settings_title"
|
android:title="@string/owner_info_settings_title"
|
||||||
android:summary="@string/owner_info_settings_summary"/>
|
android:summary="@string/owner_info_settings_summary"/>
|
||||||
|
|
||||||
|
@@ -45,8 +45,7 @@
|
|||||||
android:key="power_button_instantly_locks"
|
android:key="power_button_instantly_locks"
|
||||||
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
|
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
|
||||||
|
|
||||||
<PreferenceScreen
|
<com.android.settings.SingleLineSummaryPreference
|
||||||
android:fragment="com.android.settings.OwnerInfoSettings"
|
|
||||||
android:key="owner_info_settings"
|
android:key="owner_info_settings"
|
||||||
android:title="@string/owner_info_settings_title"
|
android:title="@string/owner_info_settings_title"
|
||||||
android:summary="@string/owner_info_settings_summary"/>
|
android:summary="@string/owner_info_settings_summary"/>
|
||||||
|
@@ -41,9 +41,8 @@
|
|||||||
android:key="power_button_instantly_locks"
|
android:key="power_button_instantly_locks"
|
||||||
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
|
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
|
||||||
|
|
||||||
<PreferenceScreen
|
<com.android.settings.SingleLineSummaryPreference
|
||||||
android:key="owner_info_settings"
|
android:key="owner_info_settings"
|
||||||
android:fragment="com.android.settings.OwnerInfoSettings"
|
|
||||||
android:title="@string/owner_info_settings_title"
|
android:title="@string/owner_info_settings_title"
|
||||||
android:summary="@string/owner_info_settings_summary"/>
|
android:summary="@string/owner_info_settings_summary"/>
|
||||||
|
|
||||||
|
@@ -16,110 +16,105 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.app.DialogFragment;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.text.Editable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
|
||||||
public class OwnerInfoSettings extends InstrumentedFragment {
|
public class OwnerInfoSettings extends DialogFragment implements OnClickListener {
|
||||||
|
|
||||||
public static final String EXTRA_SHOW_NICKNAME = "show_nickname";
|
private static final String TAG_OWNER_INFO = "ownerInfo";
|
||||||
|
|
||||||
|
private static final int MAX_CHARS = 100;
|
||||||
|
|
||||||
private View mView;
|
private View mView;
|
||||||
private CheckBox mCheckbox;
|
|
||||||
private int mUserId;
|
private int mUserId;
|
||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
private EditText mOwnerInfo;
|
private EditText mOwnerInfo;
|
||||||
private EditText mNickname;
|
private TextView mOwnerInfoStatus;
|
||||||
private boolean mShowNickname;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
Bundle args = getArguments();
|
mUserId = UserHandle.myUserId();
|
||||||
if (args != null && args.containsKey(EXTRA_SHOW_NICKNAME)) {
|
mLockPatternUtils = new LockPatternUtils(getActivity());
|
||||||
mShowNickname = args.getBoolean(EXTRA_SHOW_NICKNAME);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
Bundle savedInstanceState) {
|
mView = LayoutInflater.from(getActivity()).inflate(R.layout.ownerinfo, null);
|
||||||
mView = inflater.inflate(R.layout.ownerinfo, container, false);
|
|
||||||
mUserId = UserHandle.myUserId();
|
|
||||||
mLockPatternUtils = new LockPatternUtils(getActivity());
|
|
||||||
initView();
|
initView();
|
||||||
return mView;
|
return new AlertDialog.Builder(getActivity())
|
||||||
|
.setTitle(R.string.owner_info_settings_title)
|
||||||
|
.setView(mView)
|
||||||
|
.setPositiveButton(R.string.save, this)
|
||||||
|
.setNegativeButton(R.string.cancel, this)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initView() {
|
private void initView() {
|
||||||
mNickname = (EditText) mView.findViewById(R.id.owner_info_nickname);
|
|
||||||
if (!mShowNickname) {
|
|
||||||
mNickname.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
mNickname.setText(UserManager.get(getActivity()).getUserName());
|
|
||||||
mNickname.setSelected(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
final boolean enabled = mLockPatternUtils.isOwnerInfoEnabled();
|
|
||||||
|
|
||||||
mCheckbox = (CheckBox) mView.findViewById(R.id.show_owner_info_on_lockscreen_checkbox);
|
|
||||||
mCheckbox.setChecked(enabled);
|
|
||||||
if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
|
|
||||||
if (UserManager.get(getActivity()).isLinkedUser()) {
|
|
||||||
mCheckbox.setText(R.string.show_profile_info_on_lockscreen_label);
|
|
||||||
} else {
|
|
||||||
mCheckbox.setText(R.string.show_user_info_on_lockscreen_label);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
mLockPatternUtils.setOwnerInfoEnabled(isChecked);
|
|
||||||
mOwnerInfo.setEnabled(isChecked); // disable text field if not enabled
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
String info = mLockPatternUtils.getOwnerInfo(mUserId);
|
String info = mLockPatternUtils.getOwnerInfo(mUserId);
|
||||||
|
|
||||||
mOwnerInfo = (EditText) mView.findViewById(R.id.owner_info_edit_text);
|
mOwnerInfo = (EditText) mView.findViewById(R.id.owner_info_edit_text);
|
||||||
mOwnerInfo.setEnabled(enabled);
|
|
||||||
if (!TextUtils.isEmpty(info)) {
|
if (!TextUtils.isEmpty(info)) {
|
||||||
mOwnerInfo.setText(info);
|
mOwnerInfo.setText(info);
|
||||||
}
|
}
|
||||||
|
mOwnerInfoStatus = (TextView) mView.findViewById(R.id.owner_info_status);
|
||||||
|
updateOwnerInfoStatus();
|
||||||
|
|
||||||
|
mOwnerInfo.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
updateOwnerInfoStatus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateOwnerInfoStatus() {
|
||||||
|
String status = getString(R.string.owner_info_settings_status,
|
||||||
|
mOwnerInfo.getText().toString().length(), MAX_CHARS);
|
||||||
|
mOwnerInfoStatus.setText(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMetricsCategory() {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
return MetricsLogger.OWNER_INFO;
|
if (which == AlertDialog.BUTTON_POSITIVE) {
|
||||||
}
|
String info = mOwnerInfo.getText().toString();
|
||||||
|
mLockPatternUtils.setOwnerInfoEnabled(!TextUtils.isEmpty(info));
|
||||||
|
mLockPatternUtils.setOwnerInfo(info, mUserId);
|
||||||
|
|
||||||
@Override
|
if (getTargetFragment() instanceof SecuritySettings) {
|
||||||
public void onPause() {
|
((SecuritySettings) getTargetFragment()).updateOwnerInfo();
|
||||||
super.onPause();
|
|
||||||
saveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveChanges() {
|
|
||||||
String info = mOwnerInfo.getText().toString();
|
|
||||||
mLockPatternUtils.setOwnerInfo(info, mUserId);
|
|
||||||
if (mShowNickname) {
|
|
||||||
String oldName = UserManager.get(getActivity()).getUserName();
|
|
||||||
CharSequence newName = mNickname.getText();
|
|
||||||
if (!TextUtils.isEmpty(newName) && !newName.equals(oldName)) {
|
|
||||||
UserManager.get(getActivity()).setUserName(UserHandle.myUserId(),
|
|
||||||
newName.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void show(Fragment parent) {
|
||||||
|
if (!parent.isAdded()) return;
|
||||||
|
|
||||||
|
final OwnerInfoSettings dialog = new OwnerInfoSettings();
|
||||||
|
dialog.setTargetFragment(parent, 0);
|
||||||
|
dialog.show(parent.getFragmentManager(), TAG_OWNER_INFO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,8 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
|
||||||
|
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
@@ -26,26 +28,26 @@ import android.content.DialogInterface;
|
|||||||
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.pm.UserInfo;
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.hardware.fingerprint.Fingerprint;
|
||||||
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.preference.SwitchPreference;
|
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.preference.SwitchPreference;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.security.KeyStore;
|
import android.security.KeyStore;
|
||||||
import android.hardware.fingerprint.Fingerprint;
|
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
|
||||||
import android.service.trust.TrustAgentService;
|
import android.service.trust.TrustAgentService;
|
||||||
import android.telephony.TelephonyManager;
|
|
||||||
import android.telephony.SubscriptionManager;
|
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
|
import android.telephony.SubscriptionManager;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -60,8 +62,6 @@ import com.android.settings.search.SearchIndexableRaw;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gesture lock pattern settings.
|
* Gesture lock pattern settings.
|
||||||
*/
|
*/
|
||||||
@@ -129,6 +129,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
private boolean mIsPrimary;
|
private boolean mIsPrimary;
|
||||||
|
|
||||||
private Intent mTrustAgentClickIntent;
|
private Intent mTrustAgentClickIntent;
|
||||||
|
private Preference mOwnerInfoPref;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMetricsCategory() {
|
protected int getMetricsCategory() {
|
||||||
@@ -202,16 +203,15 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
// Add options for device encryption
|
// Add options for device encryption
|
||||||
mIsPrimary = UserHandle.myUserId() == UserHandle.USER_OWNER;
|
mIsPrimary = UserHandle.myUserId() == UserHandle.USER_OWNER;
|
||||||
|
|
||||||
if (!mIsPrimary) {
|
mOwnerInfoPref = findPreference(KEY_OWNER_INFO_SETTINGS);
|
||||||
// Rename owner info settings
|
if (mOwnerInfoPref != null) {
|
||||||
Preference ownerInfoPref = findPreference(KEY_OWNER_INFO_SETTINGS);
|
mOwnerInfoPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
if (ownerInfoPref != null) {
|
@Override
|
||||||
if (UserManager.get(getActivity()).isLinkedUser()) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
ownerInfoPref.setTitle(R.string.profile_info_settings_title);
|
OwnerInfoSettings.show(SecuritySettings.this);
|
||||||
} else {
|
return true;
|
||||||
ownerInfoPref.setTitle(R.string.user_info_settings_title);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsPrimary) {
|
if (mIsPrimary) {
|
||||||
@@ -603,6 +603,16 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
if (mResetCredentials != null) {
|
if (mResetCredentials != null) {
|
||||||
mResetCredentials.setEnabled(!mKeyStore.isEmpty());
|
mResetCredentials.setEnabled(!mKeyStore.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateOwnerInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateOwnerInfo() {
|
||||||
|
if (mOwnerInfoPref != null) {
|
||||||
|
mOwnerInfoPref.setSummary(mLockPatternUtils.isOwnerInfoEnabled()
|
||||||
|
? mLockPatternUtils.getOwnerInfo(UserHandle.myUserId())
|
||||||
|
: getString(R.string.owner_info_settings_summary));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
41
src/com/android/settings/SingleLineSummaryPreference.java
Normal file
41
src/com/android/settings/SingleLineSummaryPreference.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 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 android.content.Context;
|
||||||
|
import android.preference.Preference;
|
||||||
|
import android.text.TextUtils.TruncateAt;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class SingleLineSummaryPreference extends Preference {
|
||||||
|
|
||||||
|
public SingleLineSummaryPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBindView(View view) {
|
||||||
|
super.onBindView(view);
|
||||||
|
|
||||||
|
final TextView summaryView = (TextView) view.findViewById(
|
||||||
|
com.android.internal.R.id.summary);
|
||||||
|
summaryView.setSingleLine();
|
||||||
|
summaryView.setEllipsize(TruncateAt.END);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -461,16 +461,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
null, 0);
|
null, 0);
|
||||||
} else if (info.id == UserHandle.myUserId()) {
|
} else if (info.id == UserHandle.myUserId()) {
|
||||||
// Jump to owner info panel
|
// Jump to owner info panel
|
||||||
Bundle extras = new Bundle();
|
OwnerInfoSettings.show(this);
|
||||||
if (!info.isRestricted()) {
|
|
||||||
extras.putBoolean(OwnerInfoSettings.EXTRA_SHOW_NICKNAME, true);
|
|
||||||
}
|
|
||||||
int titleResId = info.id == UserHandle.USER_OWNER ? R.string.owner_info_settings_title
|
|
||||||
: (info.isRestricted() ? R.string.profile_info_settings_title
|
|
||||||
: R.string.user_info_settings_title);
|
|
||||||
((SettingsActivity) getActivity()).startPreferencePanel(
|
|
||||||
OwnerInfoSettings.class.getName(),
|
|
||||||
extras, titleResId, null, null, 0);
|
|
||||||
} else if (mIsOwner) {
|
} else if (mIsOwner) {
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putInt(UserDetailsSettings.EXTRA_USER_ID, userId);
|
extras.putInt(UserDetailsSettings.EXTRA_USER_ID, userId);
|
||||||
|
Reference in New Issue
Block a user