2 * Copyright (C) 2010 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.settings;
19 import android.app.Fragment;
20 import android.content.ContentResolver;
21 import android.os.Bundle;
22 import android.provider.Settings;
23 import android.text.Editable;
24 import android.text.TextWatcher;
25 import android.view.LayoutInflater;
26 import android.view.View;
27 import android.view.ViewGroup;
28 import android.widget.CheckBox;
29 import android.widget.CompoundButton;
30 import android.widget.EditText;
31 import android.widget.CompoundButton.OnCheckedChangeListener;
33 public class OwnerInfo extends Fragment {
35 private CheckBox mCheckbox;
36 private EditText mEditText;
39 public View onCreateView(LayoutInflater inflater, ViewGroup container,
40 Bundle savedInstanceState) {
41 mView = inflater.inflate(R.layout.ownerinfo, container, false);
46 private void initView(View view) {
47 final ContentResolver res = getActivity().getContentResolver();
48 String info = Settings.Secure.getString(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO);
49 int enabled = Settings.Secure.getInt(res,
50 Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED, 1);
51 mCheckbox = (CheckBox) mView.findViewById(R.id.show_owner_info_on_lockscreen_checkbox);
52 mEditText = (EditText) mView.findViewById(R.id.owner_info_edit_text);
53 mEditText.setText(info);
54 mEditText.setEnabled(enabled != 0);
55 mCheckbox.setChecked(enabled != 0);
56 mCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
57 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
58 Settings.Secure.putInt(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED,
60 mEditText.setEnabled(isChecked); // disable text field if not enabled
66 public void onPause() {
72 ContentResolver res = getActivity().getContentResolver();
73 String info = mEditText.getText().toString();
74 Settings.Secure.putString(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO, info);