Merge branch 'master' into honeycomb-release

This commit is contained in:
The Android Automerger
2010-10-20 07:16:43 -07:00
5 changed files with 126 additions and 48 deletions

View File

@@ -18,8 +18,8 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:keepScreenOn="true"
android:paddingTop="70dip"
android:paddingBottom="80dip"
android:paddingTop="140dip"
android:paddingBottom="60dip"
android:paddingLeft="60dip"
android:paddingRight="60dip">
@@ -53,22 +53,33 @@
android:layout_width="0px"
android:layout_weight=".4"
android:layout_height="fill_parent"
android:paddingTop="20dip"
android:paddingTop="80dip"
android:paddingLeft="50dip"
android:paddingRight="50dip"
android:paddingBottom="15dip">
<!-- divider -->
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_marginBottom="4dip"
android:background="@color/divider_color" />
<!-- Assume the text size of this text should be same as Preference's
texts. See also preference.xml -->
<TextView android:id="@+id/wifi_setup_status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff555555"
android:background="#00000000"
android:textColor="#ff666666"
android:paddingLeft="5dip"
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:layout_marginBottom="20dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/wifi_setup_status_select_network"/>
<!-- divider -->
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_marginTop="4dip"
android:layout_marginBottom="20dip"
android:background="@color/divider_color" />
<fragment class="com.android.settings.wifi.WifiSettings"
android:id="@+id/wifi_setup_fragment"
android:layout_width="fill_parent"
@@ -80,14 +91,17 @@
android:layout_width="0px"
android:layout_weight=".3"
android:layout_height="fill_parent"
android:gravity="right"
android:paddingTop="22dip"
android:paddingLeft="50dip"
android:paddingRight="50dip"
android:paddingBottom="10dip">
<TextView android:id="@+id/scanning_progress_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textSize="24dip"/>
android:gravity="right"
android:textSize="22dip"
android:textColor="#ff40520f" />
<ProgressBar android:id="@+id/scanning_progress_bar"
android:layout_width="220dip"
android:layout_height="wrap_content"
@@ -95,40 +109,45 @@
style="?android:attr/progressBarStyleHorizontal" />
<Button android:id="@+id/wifi_setup_connect"
android:layout_width="220dip"
android:layout_height="wrap_content"
android:layout_width="260dip"
android:layout_height="60dip"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:textSize="24dip"
android:text="@string/wifi_connect"
android:visibility="gone" />
<Button android:id="@+id/wifi_setup_forget"
android:layout_width="220dip"
android:layout_height="wrap_content"
android:layout_width="260dip"
android:layout_height="60dip"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:textSize="24dip"
android:text="@string/wifi_forget"
android:visibility="gone" />
<Button android:id="@+id/wifi_setup_add_network"
android:layout_width="220dip"
android:layout_height="wrap_content"
android:layout_width="260dip"
android:layout_height="60dip"
android:layout_above="@+id/wifi_setup_refresh_list"
android:layout_alignParentRight="true"
android:textSize="24dip"
android:text="@string/wifi_setup_add_network"
android:enabled="false" />
<Button android:id="@+id/wifi_setup_refresh_list"
android:layout_width="220dip"
android:layout_height="wrap_content"
android:layout_width="260dip"
android:layout_height="60dip"
android:layout_above="@+id/wifi_setup_skip_or_next"
android:layout_alignParentRight="true"
android:textSize="24dip"
android:text="@string/wifi_setup_refresh_list"
android:enabled="false" />
<Button android:id="@+id/wifi_setup_skip_or_next"
android:layout_width="220dip"
android:layout_height="wrap_content"
android:layout_width="260dip"
android:layout_height="60dip"
android:layout_marginTop="30dip"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:textSize="24dip"
android:text="@string/wifi_setup_skip"

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (C) 2010 Google Inc.
*
* 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.
*/
-->
<resources>
<color name="divider_color">#ff222222</color>
</resources>

View File

@@ -869,6 +869,7 @@
<string name="nfc_quick_toggle_title">NFC</string>
<!-- Used in the 1st-level settings screen as the turn-on summary -->
<string name="nfc_quick_toggle_summary">Use Near Field Communication to read and exchange tags</string>
<string name="nfc_toggle_error" msgid="8998642457947607263">An error occurred.</string>
<!-- Wi-Fi Settings --> <skip />
<!-- Used in the 1st-level settings screen to turn on Wi-Fi -->
@@ -1335,9 +1336,9 @@
<!-- About phone screen, summary of the item to go into the phone status screen -->
<string name="device_status_summary">Phone number, signal, etc.</string>
<!-- Main settings screen item's title to go into the SD card and storage settings screen [CHAR LIMIT=25] -->
<string name="storage_settings" product="nosdcard">Shared &amp; secure storage storage</string>
<string name="storage_settings" product="nosdcard">Shared &amp; secure storage</string>
<!-- Main settings screen item's title to go into the SD card and storage settings screen-->
<string name="storage_settings">Storage</string>
<string name="storage_settings" product="default">Storage</string>
<!-- SD card and storage settings screen title -->
<string name="storage_settings_title">Storage settings</string>
<!-- [CHAR LIMIT=100] Main settings screen item's summary for the SD card and storage settings -->
@@ -1412,7 +1413,7 @@
<!-- SD card & phone storage settings item title that will result in the phone mounting the SD card. [CHAR LIMIT=30] -->
<string name="sd_mount_summary" product="nosdcard">Mount the internal USB storage</string>
<!-- SD card & phone storage settings item title that will result in the phone mounting the SD card. -->
<string name="sd_mount_summary">Mount the SD card</string>
<string name="sd_mount_summary" product="default">Mount the SD card</string>
<!-- SD card & phone storage settings item title that will result in the phone formatting the USB storage. [CHAR LIMIT=25] -->
<string name="sd_format" product="nosdcard">Erase USB storage</string>
<!-- SD card & phone storage settings item title that will result in the phone formatting the SD card. [CHAR LIMIT=25] -->

View File

@@ -17,10 +17,15 @@
package com.android.settings.nfc;
import com.android.settings.R;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.nfc.NfcAdapter;
import android.preference.Preference;
import android.os.Handler;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.provider.Settings;
import android.util.Log;
@@ -35,6 +40,20 @@ public class NfcEnabler implements Preference.OnPreferenceChangeListener {
private final Context mContext;
private final CheckBoxPreference mCheckbox;
private final NfcAdapter mNfcAdapter;
private final IntentFilter mIntentFilter;
private final Handler mHandler = new Handler();
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (NfcAdapter.ACTION_ADAPTER_STATE_CHANGE.equals(action)) {
handleNfcStateChanged(intent.getBooleanExtra(
NfcAdapter.EXTRA_NEW_BOOLEAN_STATE,
false));
}
}
};
private boolean mNfcState;
@@ -47,49 +66,66 @@ public class NfcEnabler implements Preference.OnPreferenceChangeListener {
// NFC is not supported
mCheckbox.setEnabled(false);
}
mIntentFilter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGE);
}
public void resume() {
if (mNfcAdapter == null) {
return;
}
mCheckbox.setOnPreferenceChangeListener(this);
mNfcState = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.NFC_ON, 0) != 0;
updateUi();
mContext.registerReceiver(mReceiver, mIntentFilter);
mCheckbox.setOnPreferenceChangeListener(this);
mNfcState = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.NFC_ON, 0) != 0;
mCheckbox.setChecked(mNfcState);
}
public void pause() {
if (mNfcAdapter == null) {
return;
}
mContext.unregisterReceiver(mReceiver);
mCheckbox.setOnPreferenceChangeListener(null);
}
public boolean onPreferenceChange(Preference preference, Object value) {
// Turn on/off Nfc
mNfcState = (Boolean) value;
setEnabled();
// Turn NFC on/off
final boolean desiredState = (Boolean) value;
mCheckbox.setEnabled(false);
// Start async update of the NFC adapter state, as the API is
// unfortunately blocking...
new Thread("toggleNFC") {
public void run() {
Log.d(TAG, "Setting NFC enabled state to: " + desiredState);
boolean success = false;
if (desiredState) {
success = mNfcAdapter.enableTagDiscovery();
} else {
success = mNfcAdapter.disableTagDiscovery();
}
if (success) {
Log.d(TAG, "Successfully changed NFC enabled state to " + desiredState);
// UI will be updated by BroadcastReceiver, above.
} else {
Log.w(TAG, "Error setting NFC enabled state to " + desiredState);
mHandler.post(new Runnable() {
public void run() {
mCheckbox.setEnabled(true);
mCheckbox.setSummary(R.string.nfc_toggle_error);
}
});
}
}
}.start();
return false;
}
private void setEnabled() {
if (mNfcState) {
if (!mNfcAdapter.enableTagDiscovery()) {
Log.w(TAG, "NFC enabling failed");
mNfcState = false;
}
} else {
if (!mNfcAdapter.disableTagDiscovery()) {
Log.w(TAG, "NFC disabling failed");
mNfcState = true;
}
}
updateUi();
}
private void updateUi() {
mCheckbox.setChecked(mNfcState);
private void handleNfcStateChanged(boolean newState) {
mCheckbox.setChecked(newState);
mCheckbox.setEnabled(true);
}
}

View File

@@ -93,7 +93,7 @@ public class WifiSettings extends SettingsPreferenceFragment
// ListView won't become larger than the screen.
//
// This constant doesn't affect other contexts other than SetupWizard XL.
private static int MAX_MENU_COUNT_IN_XL = 7;
private static int MAX_MENU_COUNT_IN_XL = 6;
private final IntentFilter mFilter;
private final BroadcastReceiver mReceiver;