Code drop from //branches/cupcake/...@124589

This commit is contained in:
The Android Open Source Project
2008-12-17 18:04:04 -08:00
parent 5c11852110
commit e943f2fd8e
659 changed files with 47382 additions and 9976 deletions

View File

@@ -0,0 +1,156 @@
/*
**
** Copyright 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.development;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class AppHwConfigList extends ListActivity {
private static final String TAG = "AppHwConfigList";
PackageManager mPm;
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
mPm = getPackageManager();
mAdapter = new AppListAdapter(this);
if (mAdapter.getCount() <= 0) {
finish();
} else {
setListAdapter(mAdapter);
}
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
PackageInfo app = mAdapter.appForPosition(position);
// TODO display all preference settings
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClass(this, AppHwPref.class);
intent.putExtra("packageName", app.packageName);
startActivity(intent);
}
private final class AppListAdapter extends BaseAdapter {
public AppListAdapter(Context context) {
mContext = context;
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
List<ApplicationInfo> appList = mPm.getInstalledApplications(0);
for (ApplicationInfo app : appList) {
PackageInfo pkgInfo = null;
try {
pkgInfo = mPm.getPackageInfo(app.packageName, 0);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if ((pkgInfo != null)) {
if(mList == null) {
mList = new ArrayList<PackageInfo>();
}
mList.add(pkgInfo);
}
}
if (mList != null) {
Collections.sort(mList, sDisplayNameComparator);
}
}
public PackageInfo appForPosition(int position) {
if (mList == null) {
return null;
}
return mList.get(position);
}
public int getCount() {
return mList != null ? mList.size() : 0;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View view;
if (convertView == null) {
view = mInflater.inflate(
android.R.layout.simple_list_item_1, parent, false);
} else {
view = convertView;
}
bindView(view, mList.get(position));
return view;
}
private final void bindView(View view, PackageInfo info) {
TextView text = (TextView)view.findViewById(android.R.id.text1);
text.setText(info != null ? info.applicationInfo.loadLabel(mPm) : "(none)");
}
protected final Context mContext;
protected final LayoutInflater mInflater;
protected List<PackageInfo> mList;
}
private final Comparator sDisplayNameComparator = new Comparator() {
public final int compare(Object a, Object b) {
CharSequence sa = ((PackageInfo) a).applicationInfo.loadLabel(mPm);
CharSequence sb = ((PackageInfo) b).applicationInfo.loadLabel(mPm);
return collator.compare(sa, sb);
}
private final Collator collator = Collator.getInstance();
};
private AppListAdapter mAdapter;
}

View File

@@ -0,0 +1,228 @@
/*
**
** Copyright 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.development;
import com.android.development.R;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ConfigurationInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
/* This activity displays the hardware configuration details
* of an application as defined in its manifests
*/
public class AppHwPref extends Activity {
private static final String TAG = "AppHwPref";
PackageManager mPm;
private static final int BASE = 0;
private static final int TOUCHSCREEN = BASE + 1;
private static final int KEYBOARD_TYPE = BASE + 2;
private static final int NAVIGATION = BASE + 3;
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
Intent intent = getIntent();
String pkgName = intent.getStringExtra("packageName");
if(pkgName == null) {
handleError("Null package name", true);
return;
}
mPm = getPackageManager();
PackageInfo pInfo;
try {
pInfo = mPm.getPackageInfo(pkgName, PackageManager.GET_CONFIGURATIONS);
} catch (NameNotFoundException e) {
pInfo = null;
}
if(pInfo == null) {
handleError("Failed retrieving packageInfo for pkg:"+pkgName, true);
return;
}
ConfigurationInfo appHwPref[] = pInfo.configPreferences;
setContentView(R.layout.application_hw_pref);
if(appHwPref != null) {
displayTextView(R.id.attr_package, pInfo.applicationInfo.loadLabel(mPm));
displayTextView(R.id.attr_touchscreen, appHwPref, TOUCHSCREEN);
displayTextView(R.id.attr_input_method, appHwPref, KEYBOARD_TYPE);
displayTextView(R.id.attr_navigation, appHwPref, NAVIGATION);
displayFlag(R.id.attr_hard_keyboard, ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD, appHwPref);
displayFlag(R.id.attr_five_way_nav, ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV, appHwPref);
}
}
void displayFlag(int viewId, int flagMask, ConfigurationInfo[] appHwPref) {
if(appHwPref == null) {
return;
}
boolean flag = false;
for (int i = 0; i < appHwPref.length; i++) {
ConfigurationInfo pref = appHwPref[i];
if((pref.reqInputFeatures & flagMask) != 0) {
flag = true;
break;
}
}
if(flag) {
displayTextView(viewId, "true");
} else {
displayTextView(viewId, "false");
}
}
void handleError(String errMsg, boolean finish) {
// TODO display dialog
Log.i(TAG, errMsg);
if(finish) {
finish();
}
}
void displayTextView(int textViewId, CharSequence displayStr) {
TextView tView = (TextView) findViewById(textViewId);
if(displayStr != null) {
tView.setText(displayStr);
}
}
void displayTextView(int viewId, ConfigurationInfo[] config, int type) {
if((config == null) || (config.length < 1)) {
return;
}
HashSet<String> list = new HashSet<String>();
for(int i = 0; i < config.length; i++) {
String str = null;
switch(type) {
case TOUCHSCREEN:
str = getTouchScreenStr(config[i]);
break;
case KEYBOARD_TYPE:
str = getKeyboardTypeStr(config[i]);
break;
case NAVIGATION:
str = getNavigationStr(config[i]);
break;
}
if(str != null) {
list.add(str);
}
}
String listStr = "";
boolean set = false;
for(String str : list) {
set = true;
listStr += str+",";
}
if(set) {
TextView tView = (TextView)findViewById(viewId);
CharSequence txt = listStr.subSequence(0, listStr.length()-1);
tView.setText(txt);
}
}
String getTouchScreenStr(ConfigurationInfo appHwPref) {
if(appHwPref == null) {
handleError("Invalid HardwareConfigurationObject", true);
return null;
}
switch(appHwPref.reqTouchScreen) {
case Configuration.TOUCHSCREEN_FINGER:
return "finger";
case Configuration.TOUCHSCREEN_NOTOUCH:
return "notouch";
case Configuration.TOUCHSCREEN_STYLUS:
return "stylus";
case Configuration.TOUCHSCREEN_UNDEFINED:
return null;
default:
return null;
}
}
String getKeyboardTypeStr(ConfigurationInfo appHwPref) {
if(appHwPref == null) {
handleError("Invalid HardwareConfigurationObject", true);
return null;
}
switch(appHwPref.reqKeyboardType) {
case Configuration.KEYBOARD_12KEY:
return "12key";
case Configuration.KEYBOARD_NOKEYS:
return "nokeys";
case Configuration.KEYBOARD_QWERTY:
return "querty";
case Configuration.KEYBOARD_UNDEFINED:
return null;
default:
return null;
}
}
String getNavigationStr(ConfigurationInfo appHwPref) {
if(appHwPref == null) {
handleError("Invalid HardwareConfigurationObject", true);
return null;
}
switch(appHwPref.reqNavigation) {
case Configuration.NAVIGATION_DPAD:
return "dpad";
case Configuration.NAVIGATION_TRACKBALL:
return "trackball";
case Configuration.NAVIGATION_WHEEL:
return "wheel";
case Configuration.NAVIGATION_UNDEFINED:
return null;
default:
return null;
}
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onStop() {
super.onStop();
}
}

View File

@@ -49,7 +49,6 @@ public class DevelopmentSettings extends Activity {
private static final int DEBUG_APP_REQUEST = 1;
private Button mDebugAppButton;
private CheckBox mEnableAdbCB;
private CheckBox mWaitForDebuggerCB;
private CheckBox mAlwaysFinishCB;
private CheckBox mShowLoadCB;
@@ -59,7 +58,6 @@ public class DevelopmentSettings extends Activity {
private CheckBox mShowBackgroundCB;
private CheckBox mShowSleepCB;
private CheckBox mShowMapsCompassCB;
private CheckBox mKeepScreenOnCB;
private CheckBox mShowXmppCB;
private Spinner mMaxProcsSpinner;
private Spinner mWindowAnimationScaleSpinner;
@@ -67,13 +65,11 @@ public class DevelopmentSettings extends Activity {
private Spinner mFontHintingSpinner;
private String mDebugApp;
private boolean mEnableAdb;
private boolean mWaitForDebugger;
private boolean mAlwaysFinish;
private int mProcessLimit;
private boolean mShowSleep;
private boolean mShowMapsCompass;
private boolean mKeepScreenOn;
private boolean mShowXmpp;
private AnimationScaleSelectedListener mWindowAnimationScale
= new AnimationScaleSelectedListener(0);
@@ -93,8 +89,6 @@ public class DevelopmentSettings extends Activity {
mDebugAppButton = (Button)findViewById(R.id.debug_app);
mDebugAppButton.setOnClickListener(mDebugAppClicked);
mEnableAdbCB = (CheckBox)findViewById(R.id.enable_adb);
mEnableAdbCB.setOnClickListener(mEnableAdbClicked);
mWaitForDebuggerCB = (CheckBox)findViewById(R.id.wait_for_debugger);
mWaitForDebuggerCB.setOnClickListener(mWaitForDebuggerClicked);
mAlwaysFinishCB = (CheckBox)findViewById(R.id.always_finish);
@@ -114,8 +108,6 @@ public class DevelopmentSettings extends Activity {
mShowSleepCB.setOnClickListener(mShowSleepClicked);
mShowMapsCompassCB = (CheckBox)findViewById(R.id.show_maps_compass);
mShowMapsCompassCB.setOnClickListener(mShowMapsCompassClicked);
mKeepScreenOnCB = (CheckBox)findViewById(R.id.keep_screen_on);
mKeepScreenOnCB.setOnClickListener(mKeepScreenOnClicked);
mShowXmppCB = (CheckBox)findViewById(R.id.show_xmpp);
mShowXmppCB.setOnClickListener(mShowXmppClicked);
mMaxProcsSpinner = (Spinner)findViewById(R.id.max_procs);
@@ -181,7 +173,6 @@ public class DevelopmentSettings extends Activity {
updateFlingerOptions();
updateSleepOptions();
updateMapsCompassOptions();
updateKeepScreenOnOptions();
updateXmppOptions();
try {
@@ -210,13 +201,10 @@ public class DevelopmentSettings extends Activity {
getContentResolver(), Settings.System.DEBUG_APP);
mWaitForDebugger = Settings.System.getInt(
getContentResolver(), Settings.System.WAIT_FOR_DEBUGGER, 0) != 0;
mEnableAdb = Settings.System.getInt(
getContentResolver(), Settings.System.ADB_ENABLED, 0) != 0;
mDebugAppButton.setText(
mDebugApp == null || mDebugApp.length() == 0 ? "(none)" : mDebugApp);
mWaitForDebuggerCB.setChecked(mWaitForDebugger);
mEnableAdbCB.setChecked(mEnableAdb);
}
private void writeFinishOptions() {
@@ -330,17 +318,6 @@ public class DevelopmentSettings extends Activity {
mShowMapsCompassCB.setChecked(mShowMapsCompass);
}
private void writeKeepScreenOnOptions() {
Settings.System.putInt(getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN,
mKeepScreenOn ? 1 : 0);
}
private void updateKeepScreenOnOptions() {
mKeepScreenOn = Settings.System.getInt(getContentResolver(),
Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0) != 0;
mKeepScreenOnCB.setChecked(mKeepScreenOn);
}
private void writeXmppOptions() {
Settings.System.setShowGTalkServiceStatus(getContentResolver(), mShowXmpp);
}
@@ -367,13 +344,6 @@ public class DevelopmentSettings extends Activity {
}
}
private View.OnClickListener mEnableAdbClicked = new View.OnClickListener() {
public void onClick(View v) {
Settings.System.putInt(getContentResolver(), Settings.System.ADB_ENABLED,
((CheckBox)v).isChecked() ? 1 : 0);
}
};
private View.OnClickListener mWaitForDebuggerClicked =
new View.OnClickListener() {
public void onClick(View v) {
@@ -450,15 +420,6 @@ public class DevelopmentSettings extends Activity {
};
private View.OnClickListener mKeepScreenOnClicked =
new View.OnClickListener() {
public void onClick(View v) {
mKeepScreenOn = ((CheckBox)v).isChecked();
writeKeepScreenOnOptions();
updateKeepScreenOnOptions();
}
};
private View.OnClickListener mShowXmppClicked = new View.OnClickListener() {
public void onClick(View v) {
mShowXmpp = ((CheckBox)v).isChecked();

View File

@@ -24,9 +24,9 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Bundle;
import android.pim.DateUtils;
import android.text.Editable;
import android.text.Selection;
import android.text.format.DateUtils;
import android.util.AttributeSet;
import android.view.Menu;
import android.view.MenuItem;

View File

@@ -27,12 +27,13 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
/**
@@ -52,12 +53,10 @@ public class GLSTester extends Activity {
CheckBox mDoNotify = null;
CheckBox mRunIntent = null;
Spinner mService = null;
EditText mUsernameEdit = null;
private class Listener implements View.OnClickListener {
private boolean mRequireGoogle;
public Listener(boolean requireGoogle) {
mRequireGoogle = requireGoogle;
public Listener() {
}
public void onClick(View v) {
@@ -69,7 +68,10 @@ public class GLSTester extends Activity {
String service = (String) mService.getSelectedItem();
mText.append("service: " + service + "\n");
String account = mGls.getAccount(mRequireGoogle);
String account = mUsernameEdit.getText().toString();
if (account.length() == 0) {
account = null;
}
mText.append("account: " + account + "\n");
GoogleLoginCredentialsResult result =
mGls.blockingGetCredentials(account, service, mDoNotify.isChecked());
@@ -120,6 +122,8 @@ public class GLSTester extends Activity {
setContentView(R.layout.gls_tester);
mText = (LogTextBox) findViewById(R.id.text);
mText.append("Hello, world!\n");
Log.v(TAG, "hello, world!");
mDoNotify = (CheckBox) findViewById(R.id.do_notification);
mRunIntent = (CheckBox) findViewById(R.id.run_intent);
@@ -127,11 +131,47 @@ public class GLSTester extends Activity {
mService = (Spinner) findViewById(R.id.service_spinner);
mUsernameEdit = (EditText) findViewById(R.id.username_edit);
Button b;
b = (Button) findViewById(R.id.require_google);
b.setOnClickListener(new Listener(GoogleLoginServiceConstants.REQUIRE_GOOGLE));
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
String account = mGls.getAccount(GoogleLoginServiceConstants.REQUIRE_GOOGLE);
mText.append("REQUIRE_GOOGLE gave: " + account + "\n");
mUsernameEdit.setText(account == null ? "" : account);
} catch (RemoteException e) {
mText.append("exception: " + e + "\n");
}
} });
b = (Button) findViewById(R.id.prefer_hosted);
b.setOnClickListener(new Listener(GoogleLoginServiceConstants.PREFER_HOSTED));
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
String account = mGls.getAccount(GoogleLoginServiceConstants.PREFER_HOSTED);
mText.append("PREFER_HOSTED gave: " + account + "\n");
mUsernameEdit.setText(account == null ? "" : account);
} catch (RemoteException e) {
mText.append("exception: " + e + "\n");
}
} });
b = (Button) findViewById(R.id.get_accounts);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
String[] accounts = mGls.getAccounts();
mText.append("account list: (" + accounts.length + " entries)\n");
for (String username: accounts) {
mText.append(" " + username + "\n");
}
} catch (RemoteException e) {
mText.append("exception: " + e + "\n");
}
} });
b = (Button) findViewById(R.id.clear);
b.setOnClickListener(new View.OnClickListener() {
@@ -139,6 +179,9 @@ public class GLSTester extends Activity {
mText.setText("");
} });
b = (Button) findViewById(R.id.go);
b.setOnClickListener(new Listener());
b = (Button) findViewById(R.id.wipe_passwords);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {

View File

@@ -0,0 +1,62 @@
/*
**
** Copyright 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.development;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;
public class ProcessInfo extends Activity {
PackageManager mPm;
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
Intent intent = getIntent();
String processName = intent.getStringExtra("processName");
String pkgList[] = intent.getStringArrayExtra("packageList");
mPm = getPackageManager();
setContentView(R.layout.process_info);
TextView processNameView = (TextView) findViewById(R.id.process_name);
LinearLayout pkgListView = (LinearLayout) findViewById(R.id.package_list);
if(processName != null) {
processNameView.setText(processName);
}
if(pkgList != null) {
for(String pkg : pkgList) {
TextView pkgView = new TextView(this);
pkgView.setText(pkg);
pkgListView.addView(pkgView);
}
}
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onStop() {
super.onStop();
}
}

View File

@@ -19,11 +19,11 @@ package com.android.development;
import android.app.Activity;
import android.os.Bundle;
import android.os.SystemProperties;
import android.pim.DateFormat;
import android.provider.Checkin;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import android.telephony.ServiceState;
import android.text.format.DateFormat;
import static com.android.internal.util.CharSequences.forAsciiBytes;
import android.util.Log;
import android.view.View.OnClickListener;

View File

@@ -0,0 +1,154 @@
/*
**
** Copyright 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.development;
import android.app.ActivityManager;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class RunningProcesses extends ListActivity {
PackageManager mPm;
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
mPm = getPackageManager();
mAdapter = new AppListAdapter(this);
if (mAdapter.getCount() <= 0) {
finish();
} else {
setListAdapter(mAdapter);
}
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
ListItem app = mAdapter.appForPosition(position);
// Create intent to start new activity
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClass(this, ProcessInfo.class);
intent.putExtra("processName", app.procInfo.processName);
intent.putExtra("packageList", app.procInfo.pkgList);
// start new activity to display extended information
startActivity(intent);
}
private final class AppListAdapter extends BaseAdapter {
public AppListAdapter(Context context) {
mContext = context;
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> appList = am.getRunningAppProcesses();
for (ActivityManager.RunningAppProcessInfo app : appList) {
if(mList == null) {
mList = new ArrayList<ListItem>();
}
mList.add(new ListItem(app));
}
if (mList != null) {
Collections.sort(mList, sDisplayNameComparator);
}
}
public ListItem appForPosition(int position) {
if (mList == null) {
return null;
}
return mList.get(position);
}
public int getCount() {
return mList != null ? mList.size() : 0;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View view;
if (convertView == null) {
view = mInflater.inflate(
android.R.layout.simple_list_item_1, parent, false);
} else {
view = convertView;
}
bindView(view, mList.get(position));
return view;
}
private final void bindView(View view, ListItem info) {
TextView text = (TextView)view.findViewById(android.R.id.text1);
text.setText(info != null ? info.procInfo.processName : "(none)");
}
protected final Context mContext;
protected final LayoutInflater mInflater;
protected List<ListItem> mList;
}
private final Comparator sDisplayNameComparator = new Comparator() {
public final int compare(Object a, Object b) {
CharSequence sa = ((ListItem) a).procInfo.processName;
CharSequence sb = ((ListItem) b).procInfo.processName;
return collator.compare(sa, sb);
}
private final Collator collator = Collator.getInstance();
};
private class ListItem {
ActivityManager.RunningAppProcessInfo procInfo;
public ListItem(ActivityManager.RunningAppProcessInfo pInfo) {
procInfo = pInfo;
}
}
private AppListAdapter mAdapter;
}