auto import from //branches/cupcake/...@125939

This commit is contained in:
The Android Open Source Project
2009-01-09 17:51:25 -08:00
parent abc48f80d8
commit 5962e18d0e
28 changed files with 2494 additions and 43 deletions

View File

@@ -63,7 +63,7 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
// This is the widget enabled state, not the preference toggled state
mCheckBoxPref.setEnabled(true);
mCheckBoxPref.setChecked(isAirplaneModeOn());
mCheckBoxPref.setChecked(isAirplaneModeOn(mContext));
mPhoneStateReceiver.registerIntent();
mCheckBoxPref.setOnPreferenceChangeListener(this);
@@ -74,8 +74,8 @@ public class AirplaneModeEnabler implements Preference.OnPreferenceChangeListene
mCheckBoxPref.setOnPreferenceChangeListener(null);
}
private boolean isAirplaneModeOn() {
return Settings.System.getInt(mContext.getContentResolver(),
static boolean isAirplaneModeOn(Context context) {
return Settings.System.getInt(context.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, 0) != 0;
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2006 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 java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import com.android.internal.app.IBatteryStats;
import android.app.Activity;
import android.os.BatteryStats;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
import android.widget.TextView;
public class BatteryHistory extends Activity {
private static final String TAG = "BatteryHistory";
TextView mTextView;
IBatteryStats mBatteryInfo;
private String getDump(BatteryStats stats) {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(out, true);
stats.dumpLocked(null, pw, null);
pw.flush();
pw.close();
out.close();
return new String(out.toByteArray(), 0);
} catch (IOException e) {
return "IOException";
}
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Log.i(TAG, "onCreate");
setContentView(R.layout.battery_history);
mTextView = (TextView) findViewById(R.id.text);
mBatteryInfo = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo"));
try {
BatteryStats stats = mBatteryInfo.getStatistics();
String s = getDump(stats);
mTextView.setText(s);
} catch (RemoteException e) {
mTextView.setText("Got RemoteException");
Log.e(TAG, "RemoteException:", e);
}
}
}

View File

@@ -184,8 +184,8 @@ public class BatteryInfo extends Activity {
if (mBatteryStats != null) {
try {
long awakeTimeBattery = mBatteryStats.getAwakeTimeBattery();
long awakeTimePluggedIn = mBatteryStats.getAwakeTimePlugged();
long awakeTimeBattery = mBatteryStats.getAwakeTimeBattery() / 1000;
long awakeTimePluggedIn = mBatteryStats.getAwakeTimePlugged() / 1000;
mAwakeBattery.setText(DateUtils.formatElapsedTime(awakeTimeBattery / 1000)
+ " (" + (100 * awakeTimeBattery / uptime) + "%)");
mAwakePlugged.setText(DateUtils.formatElapsedTime(awakeTimePluggedIn / 1000)

View File

@@ -80,8 +80,8 @@ public class InputMethodsSettings extends PreferenceActivity {
if (null != property.getSettingsActivity()) {
PreferenceScreen prefScreen = new PreferenceScreen(this, null);
prefScreen.setKey(property.getSettingsActivity());
// XXX TODO: handle localization properly.
prefScreen.setTitle(label + " settings");
prefScreen.setTitle(getResources().getString(
R.string.input_methods_settings_label_format, label));
getPreferenceScreen().addPreference(prefScreen);
}
}

View File

@@ -291,7 +291,7 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
//display confirmation dialog
new AlertDialog.Builder(this)
.setTitle(getString(R.string.app_not_found_dlg_title))
.setIcon(R.drawable.ic_dialog_alert)
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(getString(msgId))
.setNeutralButton(getString(R.string.dlg_ok),
new DialogInterface.OnClickListener() {
@@ -421,7 +421,7 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
//display confirmation dialog
new AlertDialog.Builder(this)
.setTitle(getString(R.string.clear_data_dlg_title))
.setIcon(R.drawable.ic_dialog_alert)
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(getString(R.string.clear_data_dlg_text))
.setPositiveButton(R.string.dlg_ok, this)
.setNegativeButton(R.string.dlg_cancel, this)

View File

@@ -39,13 +39,8 @@ public class Settings extends PreferenceActivity {
@Override
protected void onResume() {
findPreference(KEY_CALL_SETTINGS).setEnabled(!isAirplaneMode());
super.onResume();
findPreference(KEY_CALL_SETTINGS).setEnabled(!AirplaneModeEnabler.isAirplaneModeOn(this));
}
private boolean isAirplaneMode() {
return System.getInt(getContentResolver(),
System.AIRPLANE_MODE_ON, 0) > 0;
}
}

View File

@@ -111,7 +111,7 @@ public class ZoneList extends ListActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_ALPHABETICAL, 0, R.string.zone_list_menu_sort_alphabetically)
.setIcon(R.drawable.ic_menu_sort_alphabetically);
.setIcon(android.R.drawable.ic_menu_sort_alphabetically);
menu.add(0, MENU_TIMEZONE, 0, R.string.zone_list_menu_sort_by_timezone)
.setIcon(R.drawable.ic_menu_3d_globe);

View File

@@ -56,8 +56,14 @@ public class BluetoothDiscoverableEnabler implements Preference.OnPreferenceChan
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
handleModeChanged(intent.getIntExtra(BluetoothIntent.MODE,
BluetoothDevice.MODE_UNKNOWN));
/*
* TODO: remove this once the BT framework broadcasts the
* MODE_CHANGED action when going into MODE_OFF.
*/
int mode = BluetoothIntent.DISABLED_ACTION.equals(intent.getAction())
? BluetoothDevice.MODE_OFF
: intent.getIntExtra(BluetoothIntent.MODE, BluetoothDevice.MODE_UNKNOWN);
handleModeChanged(mode);
}
};
@@ -85,9 +91,10 @@ public class BluetoothDiscoverableEnabler implements Preference.OnPreferenceChan
if (mLocalManager == null) {
return;
}
mContext.registerReceiver(mReceiver,
new IntentFilter(BluetoothIntent.MODE_CHANGED_ACTION));
IntentFilter filter = new IntentFilter(BluetoothIntent.MODE_CHANGED_ACTION);
filter.addAction(BluetoothIntent.DISABLED_ACTION);
mContext.registerReceiver(mReceiver, filter);
mCheckBoxPreference.setOnPreferenceChangeListener(this);
handleModeChanged(mLocalManager.getBluetoothManager().getMode());
@@ -164,7 +171,9 @@ public class BluetoothDiscoverableEnabler implements Preference.OnPreferenceChan
private void updateCountdownSummary() {
int mode = mLocalManager.getBluetoothManager().getMode();
if (mode != BluetoothDevice.MODE_DISCOVERABLE) return;
if (mode != BluetoothDevice.MODE_DISCOVERABLE) {
return;
}
long currentTimestamp = System.currentTimeMillis();
long endTimestamp = mLocalManager.getSharedPreferences().getLong(

View File

@@ -147,7 +147,7 @@ public class BluetoothSettings extends PreferenceActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_SCAN, 0, R.string.bluetooth_scan_for_devices)
.setIcon(R.drawable.ic_menu_refresh)
.setIcon(android.R.drawable.ic_menu_refresh)
.setAlphabeticShortcut('r');
return true;
}

View File

@@ -140,7 +140,7 @@ public class QuickLaunchSettings extends PreferenceActivity implements
// Create the dialog for clearing a shortcut
return new AlertDialog.Builder(this)
.setTitle(getString(R.string.quick_launch_clear_dialog_title))
.setIcon(R.drawable.ic_dialog_alert)
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(getString(R.string.quick_launch_clear_dialog_message,
mClearDialogShortcut, mClearDialogBookmarkTitle))
.setPositiveButton(R.string.quick_launch_clear_ok_button, this)

View File

@@ -176,7 +176,7 @@ public class WifiSettings extends PreferenceActivity implements WifiLayer.Callba
.setIcon(R.drawable.ic_menu_scan_network);
menu.add(0, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
.setIcon(R.drawable.ic_menu_manage);
.setIcon(android.R.drawable.ic_menu_manage);
return true;
}