Fix 3024528: Initial implementation of owner info to enable dogfooding

This is a quick UI implementation to allow owner info to be changed
on LockScreen for dogfooding.

Change-Id: I0dc781def594d1c921c44348c130f509798a71f4
This commit is contained in:
Jim Miller
2010-10-13 21:11:07 -07:00
parent 5c9bd5f127
commit edfaaeaed7
4 changed files with 147 additions and 3 deletions

56
res/layout/ownerinfo.xml Normal file
View File

@@ -0,0 +1,56 @@
<?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:orientation="vertical"
android:paddingLeft="6dip"
android:paddingRight="6dip"
android:paddingBottom="3dip"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:scrollbars="vertical" >
<CheckBox android:id="@+id/show_owner_info_on_lockscreen_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android_layout_marginTop="20dip"
android:text="@string/show_owner_info_on_lockscreen_label"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android_layout_marginTop="20dip"
android:scrollbars="vertical" >
<EditText android:id="@+id/owner_info_edit_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="2"
android:lines="4"
android:maxLines="4"
/>
<View
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>

View File

@@ -559,7 +559,10 @@
<string name="lock_after_timeout">Lock device after timeout</string> <string name="lock_after_timeout">Lock device after timeout</string>
<!-- Security settings screen, setting option summary to change screen timeout --> <!-- Security settings screen, setting option summary to change screen timeout -->
<string name="lock_after_timeout_summary">Adjust the delay before the device automatically locks</string> <string name="lock_after_timeout_summary">Adjust the delay before the device automatically locks</string>
<!-- 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>
<!-- Text shown on top-level settings for owner info [CHAR LIMIT=20]-->
<string name="owner_info_settings_title">Owner info</string>
<!-- Main Settings screen setting option title for the item to take you the security and location screen --> <!-- Main Settings screen setting option title for the item to take you the security and location screen -->
<string name="security_settings_title">Location &amp; security</string> <string name="security_settings_title">Location &amp; security</string>
<!-- Location & security settings screen title --> <!-- Location & security settings screen title -->
@@ -2034,7 +2037,7 @@ found in the list of installed applications.</string>
<string name="runningservicedetails_stop_dlg_text">Are you sure you want to stop this system service? If you do, some <string name="runningservicedetails_stop_dlg_text">Are you sure you want to stop this system service? If you do, some
features of your phone may stop working correctly until you power it off features of your phone may stop working correctly until you power it off
and then on again.</string> and then on again.</string>
<!-- Language Settings --> <skip /> <!-- Language Settings --> <skip />
<!-- Title of setting on main settings screen. This item will take the user to the screen to tweak settings realted to locale and text --> <!-- Title of setting on main settings screen. This item will take the user to the screen to tweak settings realted to locale and text -->
<string name="language_settings">Language &amp; keyboard</string> <string name="language_settings">Language &amp; keyboard</string>

View File

@@ -109,7 +109,7 @@
<!-- Storage --> <!-- Storage -->
<header <header
android:fragment="com.android.settings.deviceinfo.Memory" android:fragment="com.android.settings.deviceinfo.Memory"
android:icon="@drawable/ic_settings_storage" android:icon="@drawable/ic_settings_storage"
android:title="@string/storage_settings"> android:title="@string/storage_settings">
@@ -156,6 +156,14 @@
android:title="@string/date_and_time_settings_title"> android:title="@string/date_and_time_settings_title">
</header> </header>
<!-- Owner info -->
<header
android:fragment="com.android.settings.OwnerInfo"
android:icon="@drawable/ic_settings_about"
android:title="@string/owner_info_settings_title">
</header>
<!-- About Device --> <!-- About Device -->
<header <header

View File

@@ -0,0 +1,77 @@
/*
* 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 android.app.Fragment;
import android.content.ContentResolver;
import android.os.Bundle;
import android.provider.Settings;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class OwnerInfo extends Fragment {
private View mView;
private CheckBox mCheckbox;
private EditText mEditText;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.ownerinfo, container, false);
initView(mView);
return mView;
}
private void initView(View view) {
final ContentResolver res = getActivity().getContentResolver();
String info = Settings.Secure.getString(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO);
int enabled = Settings.Secure.getInt(res,
Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED, 1);
mCheckbox = (CheckBox) mView.findViewById(R.id.show_owner_info_on_lockscreen_checkbox);
mEditText = (EditText) mView.findViewById(R.id.owner_info_edit_text);
mEditText.setText(info);
mEditText.setEnabled(enabled != 0);
mCheckbox.setChecked(enabled != 0);
mCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Settings.Secure.putInt(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED,
isChecked ? 1 : 0);
mEditText.setEnabled(isChecked); // disable text field if not enabled
}
});
}
@Override
public void onPause() {
super.onPause();
saveToDb();
}
void saveToDb() {
ContentResolver res = getActivity().getContentResolver();
String info = mEditText.getText().toString();
Settings.Secure.putString(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO, info);
}
}