Merge "Move owner info from Settings.Secure to LockSettings" into jb-mr2-dev
This commit is contained in:
@@ -20,7 +20,6 @@ import android.app.Fragment;
|
|||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -29,36 +28,40 @@ import android.widget.CompoundButton;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
|
|
||||||
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
|
||||||
public class OwnerInfoSettings extends Fragment {
|
public class OwnerInfoSettings extends Fragment {
|
||||||
private View mView;
|
private View mView;
|
||||||
private CheckBox mCheckbox;
|
private CheckBox mCheckbox;
|
||||||
private EditText mEditText;
|
private EditText mEditText;
|
||||||
|
private int mUserId;
|
||||||
|
private LockPatternUtils mLockPatternUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
mView = inflater.inflate(R.layout.ownerinfo, container, false);
|
mView = inflater.inflate(R.layout.ownerinfo, container, false);
|
||||||
|
mUserId = UserHandle.myUserId();
|
||||||
|
mLockPatternUtils = new LockPatternUtils(getActivity());
|
||||||
initView(mView);
|
initView(mView);
|
||||||
return mView;
|
return mView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initView(View view) {
|
private void initView(View view) {
|
||||||
final ContentResolver res = getActivity().getContentResolver();
|
final ContentResolver res = getActivity().getContentResolver();
|
||||||
String info = Settings.Secure.getString(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO);
|
String info = mLockPatternUtils.getOwnerInfo(mUserId);
|
||||||
int enabled = Settings.Secure.getInt(res,
|
boolean enabled = mLockPatternUtils.isOwnerInfoEnabled();
|
||||||
Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED, 1);
|
|
||||||
mCheckbox = (CheckBox) mView.findViewById(R.id.show_owner_info_on_lockscreen_checkbox);
|
mCheckbox = (CheckBox) mView.findViewById(R.id.show_owner_info_on_lockscreen_checkbox);
|
||||||
mEditText = (EditText) mView.findViewById(R.id.owner_info_edit_text);
|
mEditText = (EditText) mView.findViewById(R.id.owner_info_edit_text);
|
||||||
mEditText.setText(info);
|
mEditText.setText(info);
|
||||||
mEditText.setEnabled(enabled != 0);
|
mEditText.setEnabled(enabled);
|
||||||
mCheckbox.setChecked(enabled != 0);
|
mCheckbox.setChecked(enabled);
|
||||||
if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
|
if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
|
||||||
mCheckbox.setText(R.string.show_user_info_on_lockscreen_label);
|
mCheckbox.setText(R.string.show_user_info_on_lockscreen_label);
|
||||||
}
|
}
|
||||||
mCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
mCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
Settings.Secure.putInt(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED,
|
mLockPatternUtils.setOwnerInfoEnabled(isChecked);
|
||||||
isChecked ? 1 : 0);
|
|
||||||
mEditText.setEnabled(isChecked); // disable text field if not enabled
|
mEditText.setEnabled(isChecked); // disable text field if not enabled
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -71,9 +74,8 @@ public class OwnerInfoSettings extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void saveToDb() {
|
void saveToDb() {
|
||||||
ContentResolver res = getActivity().getContentResolver();
|
|
||||||
String info = mEditText.getText().toString();
|
String info = mEditText.getText().toString();
|
||||||
Settings.Secure.putString(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO, info);
|
mLockPatternUtils.setOwnerInfo(info, mUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user