- Fixed issue 146, QR Codes get clipped when encoding very large amount of data, by adding a ScrollView.

- Also added support for sharing multiple email addresses and phone numbers.

git-svn-id: https://zxing.googlecode.com/svn/trunk@864 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin 2009-02-17 17:10:23 +00:00
parent 81ef8e251c
commit bbfc82cc47
3 changed files with 57 additions and 34 deletions

View file

@ -14,28 +14,35 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/encode_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/encode_view"
android:orientation="vertical"
android:gravity="center">
<ImageView android:id="@+id/image_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:scaleType="center"/>
<TextView android:id="@+id/contents_text_view"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/encode_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:textColor="@color/contents_text"
android:textSize="20.0sp"
android:paddingBottom="8px"
android:paddingLeft="8px"
android:paddingRight="8px"/>
</LinearLayout>
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="@color/encode_view">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/encode_view"
android:orientation="vertical"
android:gravity="center">
<ImageView android:id="@+id/image_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:scaleType="center"/>
<TextView android:id="@+id/contents_text_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:textColor="@color/contents_text"
android:textSize="20.0sp"
android:paddingBottom="8px"
android:paddingLeft="8px"
android:paddingRight="8px"/>
</LinearLayout>
</ScrollView>

View file

@ -27,10 +27,9 @@ import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.View;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
@ -72,7 +71,7 @@ public final class EncodeActivity extends Activity {
public final OnGlobalLayoutListener mLayoutListener = new OnGlobalLayoutListener() {
public void onGlobalLayout() {
if (mFirstLayout) {
LinearLayout layout = (LinearLayout) findViewById(R.id.encode_view);
View layout = findViewById(R.id.encode_view);
int width = layout.getWidth();
int height = layout.getHeight();
int smallerDimension = (width < height) ? width : height;

View file

@ -44,6 +44,13 @@ public final class ShareActivity extends Activity {
Contacts.ContactMethodsColumns.DATA, // 2
};
private static final int PHONES_NUMBER_COLUMN = 1;
private static final String[] PHONES_PROJECTION = {
BaseColumns._ID, // 0
Contacts.PhonesColumns.NUMBER // 1
};
private Button mClipboardButton;
@Override
@ -141,26 +148,36 @@ public final class ShareActivity extends Activity {
return;
}
bundle.putString(Contacts.Intents.Insert.NAME, name);
int phoneColumn = contactCursor.getColumnIndex(Contacts.PhonesColumns.NUMBER);
bundle.putString(Contacts.Intents.Insert.PHONE, contactCursor.getString(phoneColumn));
contactCursor.close();
Uri phonesUri = Uri.withAppendedPath(contactUri, Contacts.People.Phones.CONTENT_DIRECTORY);
Cursor phonesCursor = resolver.query(phonesUri, PHONES_PROJECTION, null, null, null);
if (phonesCursor != null) {
int foundPhone = 0;
while (phonesCursor.moveToNext()) {
String number = phonesCursor.getString(PHONES_NUMBER_COLUMN);
if (foundPhone < Contents.PHONE_KEYS.length) {
bundle.putString(Contents.PHONE_KEYS[foundPhone], number);
foundPhone++;
}
}
phonesCursor.close();
}
Uri methodsUri = Uri.withAppendedPath(contactUri,
Contacts.People.ContactMethods.CONTENT_DIRECTORY);
Cursor methodsCursor = resolver.query(methodsUri, METHODS_PROJECTION, null, null, null);
if (methodsCursor != null) {
boolean foundEmail = false;
int foundEmail = 0;
boolean foundPostal = false;
while (methodsCursor.moveToNext()) {
int kind = methodsCursor.getInt(METHODS_KIND_COLUMN);
String data = methodsCursor.getString(METHODS_DATA_COLUMN);
switch (kind) {
case Contacts.KIND_EMAIL:
if (!foundEmail) {
// Use the first address encountered, since we can't encode multiple addresses
bundle.putString(Contacts.Intents.Insert.EMAIL, data);
foundEmail = true;
if (foundEmail < Contents.EMAIL_KEYS.length) {
bundle.putString(Contents.EMAIL_KEYS[foundEmail], data);
foundEmail++;
}
break;
case Contacts.KIND_POSTAL: