sync from main

This commit is contained in:
Jimmy Shih
2012-03-23 12:19:14 -07:00
5 changed files with 153 additions and 203 deletions
+71 -86
View File
@@ -14,93 +14,78 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:layout_width="fill_parent" >
android:orientation="vertical"> <TableLayout
<TextView
android:background="@drawable/list_bar"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:paddingLeft="10dp" android:stretchColumns="1" >
android:text="@string/send_google_title" <TableRow android:id="@+id/send_google_maps_row" >
android:textColor="@color/white" <ImageView
android:textSize="20sp"/> android:contentDescription="@string/send_google_maps"
<ScrollView android:layout_height="wrap_content"
android:layout_height="0dp" android:layout_width="wrap_content"
android:layout_margin="5dp" android:src="@drawable/maps_icon" />
android:layout_weight="1" <CheckBox
android:layout_width="fill_parent"> android:id="@+id/send_google_maps"
<TableLayout android:layout_gravity="center_vertical"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:layout_marginLeft="8dp"
android:stretchColumns="1"> android:layout_width="0dp"
android:text="@string/send_google_maps"
<!-- Google Maps --> style="@android:style/TextAppearance.DeviceDefault.Medium" />
<TableRow android:id="@+id/send_google_maps_row"> </TableRow>
<ImageView <TableRow android:id="@+id/send_google_maps_option_row" >
android:contentDescription="@string/send_google_maps" <RadioGroup
android:src="@drawable/maps_icon" android:layout_column="1"
style="@style/SendGoogleImageView"/> android:layout_height="wrap_content"
<CheckBox android:layout_marginLeft="8dp"
android:id="@+id/send_google_maps" android:layout_width="0dp" >
android:text="@string/send_google_maps" <RadioButton
style="@style/SendGoogleCheckBox"/> android:id="@+id/send_google_new_map"
</TableRow>
<TableRow android:id="@+id/send_google_maps_option_row">
<RadioGroup
android:layout_column="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_width="wrap_content"
android:layout_width="0dp"> android:text="@string/send_google_new_map"
<RadioButton style="@android:style/TextAppearance.DeviceDefault.Medium" />
android:id="@+id/send_google_new_map" <RadioButton
android:text="@string/send_google_new_map" android:id="@+id/send_google_existing_map"
style="@style/SendGoogleRadioButton"/> android:layout_height="wrap_content"
<RadioButton android:layout_width="wrap_content"
android:id="@+id/send_google_existing_map" android:text="@string/send_google_existing_map"
android:text="@string/send_google_existing_map" style="@android:style/TextAppearance.DeviceDefault.Medium" />
style="@style/SendGoogleRadioButton"/> </RadioGroup>
</RadioGroup> </TableRow>
</TableRow> <TableRow android:id="@+id/send_google_fusion_tables_row" >
<ImageView
<!-- Google Fusion Tables --> android:contentDescription="@string/send_google_fusion_tables"
<TableRow android:id="@+id/send_google_fusion_tables_row"> android:layout_height="wrap_content"
<ImageView android:layout_width="wrap_content"
android:contentDescription="@string/send_google_fusion_tables" android:src="@drawable/googledocs_icon" />
android:src="@drawable/googledocs_icon" <CheckBox
style="@style/SendGoogleImageView"/> android:id="@+id/send_google_fusion_tables"
<CheckBox android:layout_gravity="center_vertical"
android:id="@+id/send_google_fusion_tables" android:layout_height="wrap_content"
android:text="@string/send_google_fusion_tables" android:layout_marginLeft="8dp"
style="@style/SendGoogleCheckBox"/> android:layout_width="0dp"
</TableRow> android:text="@string/send_google_fusion_tables"
style="@android:style/TextAppearance.DeviceDefault.Medium" />
<!-- Google Docs --> </TableRow>
<TableRow android:id="@+id/send_google_docs_row"> <TableRow android:id="@+id/send_google_docs_row" >
<ImageView <ImageView
android:contentDescription="@string/send_google_docs" android:contentDescription="@string/send_google_docs"
android:src="@drawable/googledocs_icon" android:layout_height="wrap_content"
style="@style/SendGoogleImageView"/> android:layout_width="wrap_content"
<CheckBox android:src="@drawable/googledocs_icon" />
android:id="@+id/send_google_docs" <CheckBox
android:text="@string/send_google_docs" android:id="@+id/send_google_docs"
style="@style/SendGoogleCheckBox"/> android:layout_gravity="center_vertical"
</TableRow> android:layout_height="fill_parent"
</TableLayout> android:layout_marginLeft="8dp"
</ScrollView> android:layout_width="0dp"
<LinearLayout style="@style/ButtonLayout"> android:text="@string/send_google_docs"
<LinearLayout style="@style/ButtonSpacer"/> style="@android:style/TextAppearance.DeviceDefault.Medium" />
<Button </TableRow>
android:id="@+id/send_google_send_now" </TableLayout>
android:layout_gravity="left" </ScrollView>
android:text="@string/send_google_send_now"
style="@style/Button"/>
<Button
android:id="@+id/send_google_cancel"
android:layout_gravity="right"
android:text="@string/generic_cancel"
style="@style/Button"/>
<LinearLayout style="@style/ButtonSpacer"/>
</LinearLayout>
</LinearLayout>
+5
View File
@@ -1343,6 +1343,11 @@ limitations under the License.
found."> found.">
No account found No account found
</string> </string>
<string name="send_google_no_service_selected"
translation_description="When sending a track to Google, a message indicating that the user has
not selected any Google service and no data is sent.">
You did not select any service. No data is sent.
</string>
<string name="send_google_progress_title" <string name="send_google_progress_title"
translation_description="When sending a track to a Google service, the title on the progress translation_description="When sending a track to a Google service, the title on the progress
dialog. dialog.
-22
View File
@@ -95,28 +95,6 @@ limitations under the License.
<item name="android:layout_width">wrap_content</item> <item name="android:layout_width">wrap_content</item>
</style> </style>
<!-- Send Google CheckBox -->
<style name="SendGoogleCheckBox">
<item name="android:checked">true</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:layout_width">0dp</item>
<item name="android:textSize">18sp</item>
</style>
<!-- Send Google ImageView -->
<style name="SendGoogleImageView">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
</style>
<!-- Send Google RadioButton -->
<style name="SendGoogleRadioButton">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:textSize">18sp</item>
</style>
<style name="SensorStateLabel"> <style name="SensorStateLabel">
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item> <item name="android:layout_width">fill_parent</item>
@@ -22,6 +22,7 @@ import com.google.android.maps.mytracks.R;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@@ -30,13 +31,12 @@ import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.TableRow; import android.widget.TableRow;
import android.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;
@@ -47,10 +47,10 @@ import java.util.ArrayList;
*/ */
public class UploadServiceChooserActivity extends Activity { public class UploadServiceChooserActivity extends Activity {
private static final int SERVICE_PICKER_DIALOG = 1; private static final int DIALOG_CHOOSER_ID = 0;
private SendRequest sendRequest; private SendRequest sendRequest;
private Dialog dialog; private AlertDialog alertDialog;
private TableRow mapsTableRow; private TableRow mapsTableRow;
private TableRow fusionTablesTableRow; private TableRow fusionTablesTableRow;
@@ -64,9 +64,6 @@ public class UploadServiceChooserActivity extends Activity {
private RadioButton newMapRadioButton; private RadioButton newMapRadioButton;
private RadioButton existingMapRadioButton; private RadioButton existingMapRadioButton;
private Button cancel;
private Button send;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -76,74 +73,78 @@ public class UploadServiceChooserActivity extends Activity {
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
showDialog(SERVICE_PICKER_DIALOG); showDialog(DIALOG_CHOOSER_ID);
} }
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { if (id != DIALOG_CHOOSER_ID) {
case SERVICE_PICKER_DIALOG: return null;
dialog = new Dialog(this); }
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); View view = getLayoutInflater().inflate(R.layout.upload_service_chooser, null);
dialog.setContentView(R.layout.upload_service_chooser);
dialog.setCancelable(true); mapsTableRow = (TableRow) view.findViewById(R.id.send_google_maps_row);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { fusionTablesTableRow = (TableRow) view.findViewById(R.id.send_google_fusion_tables_row);
docsTableRow = (TableRow) view.findViewById(R.id.send_google_docs_row);
mapsCheckBox = (CheckBox) view.findViewById(R.id.send_google_maps);
fusionTablesCheckBox = (CheckBox) view.findViewById(R.id.send_google_fusion_tables);
docsCheckBox = (CheckBox) view.findViewById(R.id.send_google_docs);
mapsOptionTableRow = (TableRow) view.findViewById(R.id.send_google_maps_option_row);
newMapRadioButton = (RadioButton) view.findViewById(R.id.send_google_new_map);
existingMapRadioButton = (RadioButton) view.findViewById(R.id.send_google_existing_map);
// Setup checkboxes
OnCheckedChangeListener checkBoxListener = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton button, boolean checked) {
updateStateBySelection();
}
};
mapsCheckBox.setOnCheckedChangeListener(checkBoxListener);
fusionTablesCheckBox.setOnCheckedChangeListener(checkBoxListener);
docsCheckBox.setOnCheckedChangeListener(checkBoxListener);
// Setup initial state
initState();
// Update state based on sendRequest
updateStateBySendRequest();
// Update state based on current selection
updateStateBySelection();
alertDialog = new AlertDialog.Builder(this)
.setCancelable(true)
.setNegativeButton(R.string.generic_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface d) { public void onCancel(DialogInterface d) {
finish(); finish();
} }
}); })
.setPositiveButton(R.string.send_google_send_now, new DialogInterface.OnClickListener() {
mapsTableRow = (TableRow) dialog.findViewById(R.id.send_google_maps_row); @Override
fusionTablesTableRow = (TableRow) dialog.findViewById(R.id.send_google_fusion_tables_row); public void onClick(DialogInterface dialog, int which) {
docsTableRow = (TableRow) dialog.findViewById(R.id.send_google_docs_row);
mapsCheckBox = (CheckBox) dialog.findViewById(R.id.send_google_maps);
fusionTablesCheckBox = (CheckBox) dialog.findViewById(R.id.send_google_fusion_tables);
docsCheckBox = (CheckBox) dialog.findViewById(R.id.send_google_docs);
mapsOptionTableRow = (TableRow) dialog.findViewById(R.id.send_google_maps_option_row);
newMapRadioButton = (RadioButton) dialog.findViewById(R.id.send_google_new_map);
existingMapRadioButton = (RadioButton) dialog.findViewById(R.id.send_google_existing_map);
// Setup checkboxes
OnCheckedChangeListener checkBoxListener = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton button, boolean checked) {
updateStateBySelection();
}
};
mapsCheckBox.setOnCheckedChangeListener(checkBoxListener);
fusionTablesCheckBox.setOnCheckedChangeListener(checkBoxListener);
docsCheckBox.setOnCheckedChangeListener(checkBoxListener);
// Setup buttons
cancel = (Button) dialog.findViewById(R.id.send_google_cancel);
cancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
}
});
send = (Button) dialog.findViewById(R.id.send_google_send_now);
send.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
saveState(); saveState();
startNextActivity(); if (sendMaps() || sendFusionTables() || sendDocs()) {
startNextActivity();
} else {
Toast.makeText(UploadServiceChooserActivity.this,
R.string.send_google_no_service_selected, Toast.LENGTH_LONG).show();
finish();
}
} }
}); })
.setTitle(R.string.send_google_title)
// Setup initial state .setView(view)
initState(); .create();
return alertDialog;
// Update state based on sendRequest
updateStateBySendRequest();
// Update state based on current user selection
updateStateBySelection();
return dialog;
default:
return null;
}
} }
/** /**
@@ -186,7 +187,6 @@ public class UploadServiceChooserActivity extends Activity {
*/ */
private void updateStateBySelection() { private void updateStateBySelection() {
mapsOptionTableRow.setVisibility(sendMaps() ? View.VISIBLE : View.GONE); mapsOptionTableRow.setVisibility(sendMaps() ? View.VISIBLE : View.GONE);
send.setEnabled(sendMaps() || sendFusionTables() || sendDocs());
} }
/** /**
@@ -261,8 +261,8 @@ public class UploadServiceChooserActivity extends Activity {
} }
@VisibleForTesting @VisibleForTesting
Dialog getDialog() { AlertDialog getAlertDialog() {
return dialog; return alertDialog;
} }
@VisibleForTesting @VisibleForTesting
@@ -24,7 +24,6 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
import android.test.ActivityInstrumentationTestCase2; import android.test.ActivityInstrumentationTestCase2;
import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.RadioButton; import android.widget.RadioButton;
@@ -59,7 +58,6 @@ public class UploadServiceChooserActivityTest extends
assertTrue(getMapsCheckBox().isShown()); assertTrue(getMapsCheckBox().isShown());
assertTrue(getFusionTablesCheckBox().isShown()); assertTrue(getFusionTablesCheckBox().isShown());
assertTrue(getDocsCheckBox().isShown()); assertTrue(getDocsCheckBox().isShown());
assertTrue(getCancelButton().isEnabled());
// Clicks to disable all send items. // Clicks to disable all send items.
uploadServiceChooserActivity.runOnUiThread(new Runnable() { uploadServiceChooserActivity.runOnUiThread(new Runnable() {
@@ -79,11 +77,9 @@ public class UploadServiceChooserActivityTest extends
assertTrue(getMapsCheckBox().isShown()); assertTrue(getMapsCheckBox().isShown());
assertTrue(getFusionTablesCheckBox().isShown()); assertTrue(getFusionTablesCheckBox().isShown());
assertTrue(getDocsCheckBox().isShown()); assertTrue(getDocsCheckBox().isShown());
assertTrue(getCancelButton().isEnabled());
assertFalse(getNewMapRadioButton().isShown()); assertFalse(getNewMapRadioButton().isShown());
assertFalse(getExistingMapRadioButton().isShown()); assertFalse(getExistingMapRadioButton().isShown());
assertFalse(getSendButton().isEnabled());
} }
/** /**
@@ -94,7 +90,6 @@ public class UploadServiceChooserActivityTest extends
initialActivity(true, false, false); initialActivity(true, false, false);
instrumentation.waitForIdleSync(); instrumentation.waitForIdleSync();
assertTrue(getMapsCheckBox().isShown()); assertTrue(getMapsCheckBox().isShown());
assertTrue(getCancelButton().isEnabled());
// Clicks to enable this items. // Clicks to enable this items.
uploadServiceChooserActivity.runOnUiThread(new Runnable() { uploadServiceChooserActivity.runOnUiThread(new Runnable() {
@@ -108,8 +103,6 @@ public class UploadServiceChooserActivityTest extends
assertTrue(getMapsCheckBox().isShown()); assertTrue(getMapsCheckBox().isShown());
assertTrue(getNewMapRadioButton().isShown()); assertTrue(getNewMapRadioButton().isShown());
assertTrue(getExistingMapRadioButton().isShown()); assertTrue(getExistingMapRadioButton().isShown());
assertTrue(getSendButton().isEnabled());
assertTrue(getCancelButton().isEnabled());
} }
/** /**
@@ -120,8 +113,6 @@ public class UploadServiceChooserActivityTest extends
assertFalse(getMapsCheckBox().isShown()); assertFalse(getMapsCheckBox().isShown());
assertFalse(getFusionTablesCheckBox().isShown()); assertFalse(getFusionTablesCheckBox().isShown());
assertFalse(getDocsCheckBox().isShown()); assertFalse(getDocsCheckBox().isShown());
assertFalse(getSendButton().isEnabled());
assertTrue(getCancelButton().isEnabled());
} }
/** /**
@@ -259,35 +250,26 @@ public class UploadServiceChooserActivityTest extends
uploadServiceChooserActivity = this.getActivity(); uploadServiceChooserActivity = this.getActivity();
} }
private Button getSendButton() {
return (Button) uploadServiceChooserActivity.getDialog()
.findViewById(R.id.send_google_send_now);
}
Button getCancelButton() {
return (Button) uploadServiceChooserActivity.getDialog().findViewById(R.id.send_google_cancel);
}
private CheckBox getMapsCheckBox() { private CheckBox getMapsCheckBox() {
return (CheckBox) uploadServiceChooserActivity.getDialog().findViewById(R.id.send_google_maps); return (CheckBox) uploadServiceChooserActivity.getAlertDialog().findViewById(R.id.send_google_maps);
} }
private CheckBox getFusionTablesCheckBox() { private CheckBox getFusionTablesCheckBox() {
return (CheckBox) uploadServiceChooserActivity.getDialog().findViewById( return (CheckBox) uploadServiceChooserActivity.getAlertDialog().findViewById(
R.id.send_google_fusion_tables); R.id.send_google_fusion_tables);
} }
private CheckBox getDocsCheckBox() { private CheckBox getDocsCheckBox() {
return (CheckBox) uploadServiceChooserActivity.getDialog().findViewById(R.id.send_google_docs); return (CheckBox) uploadServiceChooserActivity.getAlertDialog().findViewById(R.id.send_google_docs);
} }
private RadioButton getNewMapRadioButton() { private RadioButton getNewMapRadioButton() {
return (RadioButton) uploadServiceChooserActivity.getDialog().findViewById( return (RadioButton) uploadServiceChooserActivity.getAlertDialog().findViewById(
R.id.send_google_new_map); R.id.send_google_new_map);
} }
private RadioButton getExistingMapRadioButton() { private RadioButton getExistingMapRadioButton() {
return (RadioButton) uploadServiceChooserActivity.getDialog().findViewById( return (RadioButton) uploadServiceChooserActivity.getAlertDialog().findViewById(
R.id.send_google_existing_map); R.id.send_google_existing_map);
} }
} }