From f9eba950e0e91cba39abbf3788888aad08273821 Mon Sep 17 00:00:00 2001 From: Matthew Simmons Date: Fri, 4 Mar 2011 19:23:37 -0500 Subject: [PATCH] code review comments --- MyTracks/res/layout/send_to_google_result.xml | 72 +++++++++---------- ...ml => send_to_google_result_list_item.xml} | 42 +++++------ MyTracks/res/values/do_not_translate.xml | 5 ++ MyTracks/res/values/strings.xml | 6 +- .../android/apps/mytracks/MyTracks.java | 20 +++++- .../io/sendtogoogle/ResultDialogFactory.java | 3 +- .../io/sendtogoogle/ResultListAdapter.java | 3 +- .../sendtogoogle/ResultDialogFactoryTest.java | 20 ++++++ .../sendtogoogle/ResultListAdapterTest.java | 22 +++++- 9 files changed, 126 insertions(+), 67 deletions(-) rename MyTracks/res/layout/{send_to_google_result_fragment.xml => send_to_google_result_list_item.xml} (57%) diff --git a/MyTracks/res/layout/send_to_google_result.xml b/MyTracks/res/layout/send_to_google_result.xml index 975eb492f..7e0c01405 100644 --- a/MyTracks/res/layout/send_to_google_result.xml +++ b/MyTracks/res/layout/send_to_google_result.xml @@ -20,46 +20,46 @@ It is used to summarize the results of uploading track data to one or more services. --> - + android:paddingTop="5dip" + android:paddingBottom="5dip" + android:paddingLeft="14dip" + android:paddingRight="14dip" + android:orientation="vertical"> + - - - - - + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_horizontal"> + + + + + + android:id="@+id/send_to_google_result_comment" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/status_mymap_info" + android:visibility="gone" + style="?android:attr/textAppearanceSmall"/> + android:id="@+id/send_to_google_result_error" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/error_please_try_again_later" + android:visibility="gone" + style="?android:attr/textAppearanceLarge"/> diff --git a/MyTracks/res/layout/send_to_google_result_fragment.xml b/MyTracks/res/layout/send_to_google_result_list_item.xml similarity index 57% rename from MyTracks/res/layout/send_to_google_result_fragment.xml rename to MyTracks/res/layout/send_to_google_result_list_item.xml index 809a071f4..045a60584 100644 --- a/MyTracks/res/layout/send_to_google_result_fragment.xml +++ b/MyTracks/res/layout/send_to_google_result_list_item.xml @@ -20,30 +20,30 @@ It will be instantiated by a custom ListAdapter - once for each service to which track data was uploaded. --> - - - + + + android:orientation="vertical"> + android:id="@+id/send_to_google_result_name" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Google Docs" + style="?android:attr/textAppearanceMedium"/> + diff --git a/MyTracks/res/values/do_not_translate.xml b/MyTracks/res/values/do_not_translate.xml index 861738bf7..116175d63 100644 --- a/MyTracks/res/values/do_not_translate.xml +++ b/MyTracks/res/values/do_not_translate.xml @@ -34,4 +34,9 @@ limitations under the License. ANT SRM_ANT_BRIDGE ZEPHYR + + + google.com/fusiontables + maps.google.com + docs.google.com diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml index 5f020924b..524dad3ed 100644 --- a/MyTracks/res/values/strings.xml +++ b/MyTracks/res/values/strings.xml @@ -278,7 +278,7 @@ limitations under the License. Your maps could not be loaded at this time! Select this Map Edit Map Details - Share Track with Friends + Share Track Delete Map from your Account Map Title: Map Description: @@ -297,7 +297,6 @@ limitations under the License. I think you might be interested in this track. To view this track use Google Earth or other mapping software. - Share track with friends Public @@ -410,11 +409,8 @@ limitations under the License. Send to... Google Fusion Tables - google.com/fusiontables Google My Maps - maps.google.com Google Docs - docs.google.com Send now Create a new map Pick an existing map diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java index 8cf96aad7..3445dda7d 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java @@ -1180,6 +1180,24 @@ public class MyTracks extends TabActivity implements OnTouchListener, final boolean sentToFusionTables = sendToGoogleDialog.getSendToFusionTables(); dialogManager.dismissDialogSafely(DIALOG_PROGRESS); + // We've finished sending the track to the user-selected services. Now + // we tell them the results of the upload, and optionally share the track. + // There are a few different paths through this code: + // + // 1. The user pre-requested a share (shareRequested == true). We're going + // to display the result dialog *without* the share button (the share + // listener will be null). The OK button listener will initiate the + // share. + // + // 2. The user did not pre-request a share, but the set of services to + // which we succeeded in uploading the track are compatible with + // sharing. We'll display a share button (the share listener will be + // non-null), and will share the link if the user clicks it. + // + // 3. The user did not pre-request a share, and the set of services to + // which we succeeded in uploading the track are incompatible with + // sharing. We won't display a share button. + final boolean canShare = getSendToFusionTablesTableId() != null || getSendToMyMapsMapId() != null; @@ -1195,8 +1213,6 @@ public class MyTracks extends TabActivity implements OnTouchListener, DialogInterface.OnClickListener onOkListener = (canShare && shareRequested) ? doShareListener : null; - - // If the share listener is null, the share button will not be displayed. DialogInterface.OnClickListener onShareListener = (canShare && !shareRequested) ? doShareListener : null; diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultDialogFactory.java b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultDialogFactory.java index c2f5b1cf7..f4d77892e 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultDialogFactory.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultDialogFactory.java @@ -19,6 +19,7 @@ import com.google.android.maps.mytracks.R; import android.app.Activity; import android.app.AlertDialog; +import android.app.Dialog; import android.content.DialogInterface; import android.view.View; import android.widget.ListView; @@ -89,7 +90,7 @@ public class ResultDialogFactory { private static View makeDialogContent(Activity activity, List results, boolean success) { ResultListAdapter resultListAdapter = new ResultListAdapter(activity, - R.layout.send_to_google_result_fragment, results); + R.layout.send_to_google_result_list_item, results); View content = activity.getLayoutInflater().inflate(R.layout.send_to_google_result, null); ListView resultList = (ListView) content.findViewById(R.id.send_to_google_result_list); diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapter.java b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapter.java index a49c50c8d..68653067b 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapter.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapter.java @@ -23,6 +23,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; +import android.widget.ListAdapter; import android.widget.TextView; import java.util.List; @@ -44,7 +45,7 @@ class ResultListAdapter extends ArrayAdapter { if (view == null) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = inflater.inflate(R.layout.send_to_google_result_fragment, null); + view = inflater.inflate(R.layout.send_to_google_result_list_item, null); } SendResult result = getItem(position); diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultDialogFactoryTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultDialogFactoryTest.java index 96ed7a85d..c88035e71 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultDialogFactoryTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultDialogFactoryTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package com.google.android.apps.mytracks.io.sendtogoogle; import com.google.android.apps.mytracks.MyTracks; @@ -13,6 +28,11 @@ import android.widget.ListView; import java.util.ArrayList; import java.util.List; +/** + * Tests {@link ResultDialogFactory}. + * + * @author Matthew Simmons + */ public class ResultDialogFactoryTest extends ActivityInstrumentationTestCase2 { public ResultDialogFactoryTest() { super(MyTracks.class); diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapterTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapterTest.java index 55e1054b8..eb0dcb5f2 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapterTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapterTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ package com.google.android.apps.mytracks.io.sendtogoogle; import com.google.android.maps.mytracks.R; @@ -10,6 +25,11 @@ import android.view.View; import java.util.ArrayList; import java.util.List; +/** + * Tests {@link ResultListAdapter}. + * + * @author Matthew Simmons + */ public class ResultListAdapterTest extends AndroidTestCase { private static class TestResultListAdapter extends ResultListAdapter { public View contentView; @@ -73,7 +93,7 @@ public class ResultListAdapterTest extends AndroidTestCase { } public void testSuccess_reusesView() { - View contentView = inflateContentView(R.layout.send_to_google_result_fragment); + View contentView = inflateContentView(R.layout.send_to_google_result_list_item); TestResultListAdapter adapter = new TestResultListAdapter(getContext(), makeResult(sendType, true)); adapter.getView(0, contentView, null);