- Fixed issue 146, QR Codes get clipped when encoding very large amount of data,...
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 17 Feb 2009 17:10:23 +0000 (17:10 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 17 Feb 2009 17:10:23 +0000 (17:10 +0000)
- Also added support for sharing multiple email addresses and phone numbers.

git-svn-id: http://zxing.googlecode.com/svn/trunk@864 59b500cc-1b3d-0410-9834-0bbf25fbcc57

android/res/layout/encode.xml
android/src/com/google/zxing/client/android/EncodeActivity.java
android/src/com/google/zxing/client/android/ShareActivity.java

index 3e01b92..7597c6c 100755 (executable)
  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>
\ No newline at end of file
index cb89f63..ebd5c55 100755 (executable)
@@ -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;
index 8dc4c0f..b42215d 100755 (executable)
@@ -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: