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
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;
/**
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;
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
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: