import android.app.Activity;
import android.content.ContentResolver;
-import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Browser;
import android.provider.Contacts;
+import android.provider.BaseColumns;
import android.text.ClipboardManager;
import android.view.View;
import android.widget.Button;
private static final int PICK_BOOKMARK = 0;
private static final int PICK_CONTACT = 1;
- private static final int METHODS_ID_COLUMN = 0;
+ //private static final int METHODS_ID_COLUMN = 0;
private static final int METHODS_KIND_COLUMN = 1;
private static final int METHODS_DATA_COLUMN = 2;
- private static final String[] METHODS_PROJECTION = new String[] {
- Contacts.People.ContactMethods._ID, // 0
- Contacts.People.ContactMethods.KIND, // 1
- Contacts.People.ContactMethods.DATA, // 2
+ private static final String[] METHODS_PROJECTION = {
+ BaseColumns._ID, // 0
+ Contacts.ContactMethodsColumns.KIND, // 1
+ Contacts.ContactMethodsColumns.DATA, // 2
};
- private Button mContactButton;
- private Button mBookmarkButton;
private Button mClipboardButton;
@Override
super.onCreate(icicle);
setContentView(R.layout.share);
- mContactButton = (Button) findViewById(R.id.contact_button);
+ Button mContactButton = (Button) findViewById(R.id.contact_button);
mContactButton.setOnClickListener(mContactListener);
- mBookmarkButton = (Button) findViewById(R.id.bookmark_button);
+ Button mBookmarkButton = (Button) findViewById(R.id.bookmark_button);
mBookmarkButton.setOnClickListener(mBookmarkListener);
mClipboardButton = (Button) findViewById(R.id.clipboard_button);
mClipboardButton.setOnClickListener(mClipboardListener);
protected void onResume() {
super.onResume();
- ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
+ ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
if (clipboard.hasText()) {
mClipboardButton.setEnabled(true);
mClipboardButton.setText(R.string.button_share_clipboard);
}
}
- @Override
- protected void onPause() {
- super.onPause();
- }
-
private final Button.OnClickListener mContactListener = new Button.OnClickListener() {
public void onClick(View v) {
startActivityForResult(new Intent(Intent.ACTION_PICK, Contacts.People.CONTENT_URI),
private final Button.OnClickListener mClipboardListener = new Button.OnClickListener() {
public void onClick(View v) {
- ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
+ ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
// Should always be true, because we grey out the clipboard button in onResume() if it's empty
if (clipboard.hasText()) {
Intent intent = new Intent(Intents.Encode.ACTION);
Cursor contactCursor = resolver.query(contactUri, null, null, null, null);
Bundle bundle = new Bundle();
if (contactCursor != null && contactCursor.moveToFirst()) {
- int nameColumn = contactCursor.getColumnIndex(Contacts.People.NAME);
+ int nameColumn = contactCursor.getColumnIndex(Contacts.PeopleColumns.NAME);
String name = contactCursor.getString(nameColumn);
if (name == null || name.length() == 0) {
// TODO: Show error
}
bundle.putString(Contacts.Intents.Insert.NAME, name);
- int phoneColumn = contactCursor.getColumnIndex(Contacts.People.NUMBER);
+ int phoneColumn = contactCursor.getColumnIndex(Contacts.PhonesColumns.NUMBER);
bundle.putString(Contacts.Intents.Insert.PHONE, contactCursor.getString(phoneColumn));
contactCursor.close();
Uri methodsUri = Uri.withAppendedPath(contactUri,
Contacts.People.ContactMethods.CONTENT_DIRECTORY);
Cursor methodsCursor = resolver.query(methodsUri, METHODS_PROJECTION, null, null, null);
- boolean foundEmail = false;
- boolean foundPostal = false;
if (methodsCursor != null) {
+ boolean foundEmail = false;
+ boolean foundPostal = false;
while (methodsCursor.moveToNext()) {
- final int kind = methodsCursor.getInt(METHODS_KIND_COLUMN);
- final String data = methodsCursor.getString(METHODS_DATA_COLUMN);
+ int kind = methodsCursor.getInt(METHODS_KIND_COLUMN);
+ String data = methodsCursor.getString(METHODS_DATA_COLUMN);
switch (kind) {
case Contacts.KIND_EMAIL:
if (!foundEmail) {