package com.google.zxing.client.android;
import android.app.Activity;
-import android.content.ComponentName;
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.text.ClipboardManager;
-import android.util.Log;
import android.view.View;
import android.widget.Button;
private static final int METHODS_KIND_COLUMN = 1;
private static final int METHODS_DATA_COLUMN = 2;
- private static final String[] METHODS_PROJECTION = new String[] {
+ private static final String[] METHODS_PROJECTION = {
Contacts.People.ContactMethods._ID, // 0
Contacts.People.ContactMethods.KIND, // 1
Contacts.People.ContactMethods.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);
private final Button.OnClickListener mBookmarkListener = new Button.OnClickListener() {
public void onClick(View v) {
- // FIXME: Not working yet
- Intent intent = new Intent();
- intent.setComponent(new ComponentName("com.android.browser",
- "com.android.browser.BrowserBookmarksPage"));
+ Intent intent = new Intent(Intent.ACTION_PICK);
+ intent.setClassName(ShareActivity.this, BookmarkPickerActivity.class.getName());
startActivityForResult(intent, PICK_BOOKMARK);
}
};
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);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case PICK_BOOKMARK:
- // FIXME: Implement
- Log.v("BOOKMARK", intent.toString());
+ showTextAsBarcode(intent.getStringExtra(Browser.BookmarkColumns.URL));
break;
case PICK_CONTACT:
// Data field is content://contacts/people/984
}
}
+ private void showTextAsBarcode(String text) {
+ Intent intent = new Intent(Intents.Encode.ACTION);
+ intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
+ intent.putExtra(Intents.Encode.DATA, text);
+ startActivity(intent);
+ }
+
/**
* Takes a contact Uri and does the necessary database lookups to retrieve that person's info,
* then sends an Encode intent to render it as a QR Code.
boolean foundPostal = false;
if (methodsCursor != null) {
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) {