fix comment 9bc0a5d1c206

This commit is contained in:
Jimmy Shih
2012-03-23 14:28:11 -07:00
parent d2a245194f
commit 362d4aff8c
21 changed files with 365 additions and 387 deletions
@@ -187,8 +187,9 @@ public class ChartActivity extends Activity implements TrackDataListener {
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { if (id != DIALOG_CHART_SETTINGS_ID) {
case DIALOG_CHART_SETTINGS_ID: return null;
}
View view = getLayoutInflater().inflate(R.layout.chart_settings, null); View view = getLayoutInflater().inflate(R.layout.chart_settings, null);
final RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.chart_settings_x); final RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.chart_settings_x);
radioGroup.check(chartView.getMode() == Mode.BY_DISTANCE radioGroup.check(chartView.getMode() == Mode.BY_DISTANCE
@@ -197,10 +198,8 @@ public class ChartActivity extends Activity implements TrackDataListener {
final CheckBox[] checkBoxes = new CheckBox[ChartView.NUM_SERIES]; final CheckBox[] checkBoxes = new CheckBox[ChartView.NUM_SERIES];
checkBoxes[ChartView.ELEVATION_SERIES] = (CheckBox) view.findViewById( checkBoxes[ChartView.ELEVATION_SERIES] = (CheckBox) view.findViewById(
R.id.chart_settings_elevation); R.id.chart_settings_elevation);
checkBoxes[ChartView.SPEED_SERIES] = (CheckBox) view.findViewById( checkBoxes[ChartView.SPEED_SERIES] = (CheckBox) view.findViewById(R.id.chart_settings_speed);
R.id.chart_settings_speed); checkBoxes[ChartView.POWER_SERIES] = (CheckBox) view.findViewById(R.id.chart_settings_power);
checkBoxes[ChartView.POWER_SERIES] = (CheckBox) view.findViewById(
R.id.chart_settings_power);
checkBoxes[ChartView.CADENCE_SERIES] = (CheckBox) view.findViewById( checkBoxes[ChartView.CADENCE_SERIES] = (CheckBox) view.findViewById(
R.id.chart_settings_cadence); R.id.chart_settings_cadence);
checkBoxes[ChartView.HEART_RATE_SERIES] = (CheckBox) view.findViewById( checkBoxes[ChartView.HEART_RATE_SERIES] = (CheckBox) view.findViewById(
@@ -210,8 +209,8 @@ public class ChartActivity extends Activity implements TrackDataListener {
for (int i = 0; i < ChartView.NUM_SERIES; i++) { for (int i = 0; i < ChartView.NUM_SERIES; i++) {
checkBoxes[i].setChecked(chartView.isChartValueSeriesEnabled(i)); checkBoxes[i].setChecked(chartView.isChartValueSeriesEnabled(i));
} }
checkBoxes[ChartView.SPEED_SERIES] checkBoxes[ChartView.SPEED_SERIES].setText(reportSpeed
.setText(reportSpeed ? R.string.stat_speed : R.string.stat_pace); ? R.string.stat_speed : R.string.stat_pace);
return new AlertDialog.Builder(this) return new AlertDialog.Builder(this)
.setCancelable(true) .setCancelable(true)
@@ -231,9 +230,6 @@ public class ChartActivity extends Activity implements TrackDataListener {
.setTitle(R.string.menu_chart_view_chart_settings) .setTitle(R.string.menu_chart_view_chart_settings)
.setView(view) .setView(view)
.create(); .create();
default:
return null;
}
} }
/** /**
@@ -66,10 +66,11 @@ public class ExportActivity extends Activity {
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { if (id != DIALOG_PROGRESS_ID) {
case DIALOG_PROGRESS_ID: return null;
progressDialog = DialogUtils.createHorizontalProgressDialog(this, }
getString(R.string.export_progress_message), new DialogInterface.OnCancelListener() { progressDialog = DialogUtils.createHorizontalProgressDialog(
this, R.string.export_progress_message, new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
exportAsyncTask.cancel(true); exportAsyncTask.cancel(true);
@@ -77,9 +78,6 @@ public class ExportActivity extends Activity {
} }
}); });
return progressDialog; return progressDialog;
default:
return null;
}
} }
/** /**
@@ -111,8 +111,8 @@ public class ImportActivity extends Activity {
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { switch (id) {
case DIALOG_PROGRESS_ID: case DIALOG_PROGRESS_ID:
progressDialog = DialogUtils.createHorizontalProgressDialog(this, progressDialog = DialogUtils.createHorizontalProgressDialog(
getString(R.string.import_progress_message), new DialogInterface.OnCancelListener() { this, R.string.import_progress_message, new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
importAsyncTask.cancel(true); importAsyncTask.cancel(true);
@@ -250,7 +250,7 @@ public class MapActivity extends com.google.android.maps.MapActivity
return PlayTrackUtils.createInstallEarthDialog(this); return PlayTrackUtils.createInstallEarthDialog(this);
case DIALOG_DELETE_CURRENT_ID: case DIALOG_DELETE_CURRENT_ID:
return DialogUtils.createConfirmationDialog(this, return DialogUtils.createConfirmationDialog(this,
getString(R.string.track_list_delete_track_confirm_message), R.string.track_list_delete_track_confirm_message,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
@@ -30,7 +30,6 @@ import com.google.android.maps.mytracks.R;
import android.app.Dialog; import android.app.Dialog;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
@@ -178,7 +177,7 @@ public class SettingsActivity extends PreferenceActivity {
switch (id) { switch (id) {
case DIALOG_CONFIRM_RESET_ID: case DIALOG_CONFIRM_RESET_ID:
return DialogUtils.createConfirmationDialog( return DialogUtils.createConfirmationDialog(
this, getString(R.string.settings_reset_confirm_message), new OnClickListener() { this, R.string.settings_reset_confirm_message, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int button) { public void onClick(DialogInterface dialog, int button) {
onResetPreferencesConfirmed(); onResetPreferencesConfirmed();
@@ -186,8 +185,8 @@ public class SettingsActivity extends PreferenceActivity {
}); });
case DIALOG_CONFIRM_ACCESS_ID: case DIALOG_CONFIRM_ACCESS_ID:
return DialogUtils.createConfirmationDialog(this, return DialogUtils.createConfirmationDialog(this,
getString(R.string.settings_sharing_allow_access_confirm_message), R.string.settings_sharing_allow_access_confirm_message,
new OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int button) { public void onClick(DialogInterface dialog, int button) {
CheckBoxPreference pref = (CheckBoxPreference) findPreference( CheckBoxPreference pref = (CheckBoxPreference) findPreference(
@@ -196,8 +195,9 @@ public class SettingsActivity extends PreferenceActivity {
} }
}); });
case DIALOG_CONFIRM_RESTORE_ID: case DIALOG_CONFIRM_RESTORE_ID:
return DialogUtils.createConfirmationDialog( return DialogUtils.createConfirmationDialog(this,
this, getString(R.string.settings_backup_restore_confirm_message), new OnClickListener() { R.string.settings_backup_restore_confirm_message,
new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(SettingsActivity.this, RestoreChooserActivity.class)); startActivity(new Intent(SettingsActivity.this, RestoreChooserActivity.class));
@@ -354,8 +354,7 @@ public class TrackList extends ListActivity
.create(); .create();
case DIALOG_DELETE_ALL_ID: case DIALOG_DELETE_ALL_ID:
return DialogUtils.createConfirmationDialog(this, return DialogUtils.createConfirmationDialog(this,
getString(R.string.track_list_delete_all_confirm_message), R.string.track_list_delete_all_confirm_message, new DialogInterface.OnClickListener() {
new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
MyTracksProviderUtils.Factory.get(TrackList.this).deleteAllTracks(); MyTracksProviderUtils.Factory.get(TrackList.this).deleteAllTracks();
@@ -369,7 +368,7 @@ public class TrackList extends ListActivity
}); });
case DIALOG_DELETE_CURRENT_ID: case DIALOG_DELETE_CURRENT_ID:
return DialogUtils.createConfirmationDialog(this, return DialogUtils.createConfirmationDialog(this,
getString(R.string.track_list_delete_track_confirm_message), R.string.track_list_delete_track_confirm_message,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
@@ -203,20 +203,17 @@ public class WaypointsList extends ListActivity implements View.OnClickListener
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { if (id != DIALOG_DELETE_CURRENT_ID) {
case DIALOG_DELETE_CURRENT_ID: return null;
}
return DialogUtils.createConfirmationDialog(this, return DialogUtils.createConfirmationDialog(this,
getString(R.string.marker_list_delete_marker_confirm_message), R.string.marker_list_delete_marker_confirm_message, new DialogInterface.OnClickListener() {
new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
providerUtils.deleteWaypoint( providerUtils.deleteWaypoint(
selectedWaypointId, new DescriptionGeneratorImpl(WaypointsList.this)); selectedWaypointId, new DescriptionGeneratorImpl(WaypointsList.this));
} }
}); });
default:
return null;
}
} }
@Override @Override
@@ -61,7 +61,6 @@ public class WelcomeActivity extends Activity {
View view = getLayoutInflater().inflate(R.layout.about, null); View view = getLayoutInflater().inflate(R.layout.about, null);
TextView aboutVersion = (TextView) view.findViewById(R.id.about_version); TextView aboutVersion = (TextView) view.findViewById(R.id.about_version);
aboutVersion.setText(SystemUtils.getMyTracksVersion(this)); aboutVersion.setText(SystemUtils.getMyTracksVersion(this));
return new AlertDialog.Builder(this) return new AlertDialog.Builder(this)
.setCancelable(true) .setCancelable(true)
.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
@@ -58,19 +58,16 @@ public class BackupActivity extends Activity {
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { if (id != DIALOG_PROGRESS_ID) {
case DIALOG_PROGRESS_ID: return null;
return DialogUtils.createSpinnerProgressDialog(this, }
getString(R.string.settings_backup_now_progress_message), return DialogUtils.createSpinnerProgressDialog(
new DialogInterface.OnCancelListener() { this, R.string.settings_backup_now_progress_message, new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
finish(); finish();
} }
}); });
default:
return null;
}
} }
/** /**
@@ -71,19 +71,16 @@ public class RestoreActivity extends Activity {
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { if (id != DIALOG_PROGRESS_ID) {
case DIALOG_PROGRESS_ID: return null;
}
return DialogUtils.createSpinnerProgressDialog(this, return DialogUtils.createSpinnerProgressDialog(this,
getString(R.string.settings_backup_restore_progress_message), R.string.settings_backup_restore_progress_message, new DialogInterface.OnCancelListener() {
new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
finish(); finish();
} }
}); });
default:
return null;
}
} }
/** /**
@@ -24,8 +24,6 @@ import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.widget.Toast; import android.widget.Toast;
@@ -91,23 +89,24 @@ public class RestoreChooserActivity extends Activity {
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { if (id != DIALOG_CHOOSER_ID) {
case DIALOG_CHOOSER_ID: return null;
}
String items[] = new String[backupDates.length]; String items[] = new String[backupDates.length];
for (int i = 0; i < backupDates.length; i++) { for (int i = 0; i < backupDates.length; i++) {
items[i] = StringUtils.formatDateTime(this, backupDates[i].getTime()); items[i] = StringUtils.formatDateTime(this, backupDates[i].getTime());
} }
return new AlertDialog.Builder(this) return new AlertDialog.Builder(this)
.setCancelable(true) .setCancelable(true)
.setItems(items, new OnClickListener() { .setItems(items, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(RestoreChooserActivity.this, RestoreActivity.class) startActivity(new Intent(RestoreChooserActivity.this, RestoreActivity.class).putExtra(
.putExtra(RestoreActivity.EXTRA_DATE, backupDates[which].getTime())); RestoreActivity.EXTRA_DATE, backupDates[which].getTime()));
finish(); finish();
} }
}) })
.setOnCancelListener(new OnCancelListener() { .setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
finish(); finish();
@@ -115,8 +114,5 @@ public class RestoreChooserActivity extends Activity {
}) })
.setTitle(R.string.settings_backup_restore_select_title) .setTitle(R.string.settings_backup_restore_select_title)
.create(); .create();
default:
return null;
}
} }
} }
@@ -28,8 +28,6 @@ import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@@ -121,9 +119,8 @@ public class SaveActivity extends Activity {
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { switch (id) {
case DIALOG_PROGRESS_ID: case DIALOG_PROGRESS_ID:
progressDialog = DialogUtils.createHorizontalProgressDialog(this, progressDialog = DialogUtils.createHorizontalProgressDialog(
getString(R.string.sd_card_progress_message), this, R.string.sd_card_progress_message, new DialogInterface.OnCancelListener() {
new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
saveAsyncTask.cancel(true); saveAsyncTask.cancel(true);
@@ -137,14 +134,14 @@ public class SaveActivity extends Activity {
.setIcon(success .setIcon(success
? android.R.drawable.ic_dialog_info : android.R.drawable.ic_dialog_alert) ? android.R.drawable.ic_dialog_info : android.R.drawable.ic_dialog_alert)
.setMessage(messageId) .setMessage(messageId)
.setOnCancelListener(new OnCancelListener() { .setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
dialog.dismiss(); dialog.dismiss();
onPostResultDialog(); onPostResultDialog();
} }
}) })
.setPositiveButton(R.string.generic_ok, new OnClickListener() { .setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int arg1) { public void onClick(DialogInterface dialog, int arg1) {
dialog.dismiss(); dialog.dismiss();
@@ -25,8 +25,6 @@ import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
@@ -122,7 +120,7 @@ public class ChooseMapActivity extends Activity {
switch (id) { switch (id) {
case DIALOG_PROGRESS_ID: case DIALOG_PROGRESS_ID:
return DialogUtils.createSpinnerProgressDialog( return DialogUtils.createSpinnerProgressDialog(
this, getString(R.string.maps_list_progress_message), new DialogInterface.OnCancelListener() { this, R.string.maps_list_progress_message, new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
asyncTask.cancel(true); asyncTask.cancel(true);
@@ -134,13 +132,13 @@ public class ChooseMapActivity extends Activity {
.setCancelable(true) .setCancelable(true)
.setIcon(android.R.drawable.ic_dialog_alert) .setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(R.string.maps_list_error) .setMessage(R.string.maps_list_error)
.setOnCancelListener(new OnCancelListener() { .setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
finish(); finish();
} }
}) })
.setPositiveButton(R.string.generic_ok, new OnClickListener() { .setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int arg1) { public void onClick(DialogInterface dialog, int arg1) {
finish(); finish();
@@ -71,21 +71,18 @@ public abstract class AbstractSendActivity extends Activity {
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { if (id != DIALOG_PROGRESS_ID) {
case DIALOG_PROGRESS_ID: return null;
progressDialog = DialogUtils.createHorizontalProgressDialog(this, }
getString(R.string.send_google_progress_message, getServiceName()), progressDialog = DialogUtils.createHorizontalProgressDialog(
new DialogInterface.OnCancelListener() { this, R.string.send_google_progress_message, new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
asyncTask.cancel(true); asyncTask.cancel(true);
startNextActivity(false, true); startNextActivity(false, true);
} }
}); }, getServiceName());
return progressDialog; return progressDialog;
default:
return null;
}
} }
/** /**
@@ -135,6 +135,16 @@ public class AccountChooserActivity extends Activity {
.setTitle(R.string.send_google_no_account_title) .setTitle(R.string.send_google_no_account_title)
.create(); .create();
case DIALOG_CHOOSER_ID: case DIALOG_CHOOSER_ID:
return createDialogChooser();
default:
return null;
}
}
/**
* Creates a dialog chooser.
*/
private Dialog createDialogChooser() {
String[] choices = new String[accounts.length]; String[] choices = new String[accounts.length];
for (int i = 0; i < accounts.length; i++) { for (int i = 0; i < accounts.length; i++) {
choices[i] = accounts[i].name; choices[i] = accounts[i].name;
@@ -174,9 +184,6 @@ public class AccountChooserActivity extends Activity {
}) })
.setTitle(R.string.send_google_choose_account_title) .setTitle(R.string.send_google_choose_account_title)
.create(); .create();
default:
return null;
}
} }
private PermissionCallback spreadsheetsCallback = new PermissionCallback() { private PermissionCallback spreadsheetsCallback = new PermissionCallback() {
@@ -80,8 +80,9 @@ public class UploadResultActivity extends Activity {
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { if (id != DIALOG_RESULT_ID) {
case DIALOG_RESULT_ID: return null;
}
View view = getLayoutInflater().inflate(R.layout.upload_result, null); View view = getLayoutInflater().inflate(R.layout.upload_result, null);
LinearLayout mapsResult = (LinearLayout) view.findViewById(R.id.upload_result_maps_result); LinearLayout mapsResult = (LinearLayout) view.findViewById(R.id.upload_result_maps_result);
@@ -89,12 +90,10 @@ public class UploadResultActivity extends Activity {
R.id.upload_result_fusion_tables_result); R.id.upload_result_fusion_tables_result);
LinearLayout docsResult = (LinearLayout) view.findViewById(R.id.upload_result_docs_result); LinearLayout docsResult = (LinearLayout) view.findViewById(R.id.upload_result_docs_result);
ImageView mapsResultIcon = (ImageView) view.findViewById( ImageView mapsResultIcon = (ImageView) view.findViewById(R.id.upload_result_maps_result_icon);
R.id.upload_result_maps_result_icon);
ImageView fusionTablesResultIcon = (ImageView) view.findViewById( ImageView fusionTablesResultIcon = (ImageView) view.findViewById(
R.id.upload_result_fusion_tables_result_icon); R.id.upload_result_fusion_tables_result_icon);
ImageView docsResultIcon = (ImageView) view.findViewById( ImageView docsResultIcon = (ImageView) view.findViewById(R.id.upload_result_docs_result_icon);
R.id.upload_result_docs_result_icon);
TextView successFooter = (TextView) view.findViewById(R.id.upload_result_success_footer); TextView successFooter = (TextView) view.findViewById(R.id.upload_result_success_footer);
TextView errorFooter = (TextView) view.findViewById(R.id.upload_result_error_footer); TextView errorFooter = (TextView) view.findViewById(R.id.upload_result_error_footer);
@@ -138,8 +137,7 @@ public class UploadResultActivity extends Activity {
AlertDialog.Builder builder = new AlertDialog.Builder(this) AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setCancelable(true) .setCancelable(true)
.setIcon(hasError ? android.R.drawable.ic_dialog_alert .setIcon(hasError ? android.R.drawable.ic_dialog_alert : android.R.drawable.ic_dialog_info)
: android.R.drawable.ic_dialog_info)
.setOnCancelListener(new DialogInterface.OnCancelListener() { .setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override @Override
public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) {
@@ -158,11 +156,10 @@ public class UploadResultActivity extends Activity {
.setTitle(hasError ? R.string.generic_error_title : R.string.generic_success_title) .setTitle(hasError ? R.string.generic_error_title : R.string.generic_success_title)
.setView(view); .setView(view);
// Add a Share URL button if showing all the options and a shareUrl // Add a Share URL button if showing all the options and a shareUrl exists
// exists
if (sendRequest.isShowAll() && shareUrl != null) { if (sendRequest.isShowAll() && shareUrl != null) {
builder.setNegativeButton(getString(R.string.send_google_result_share_url), builder.setNegativeButton(
new DialogInterface.OnClickListener() { getString(R.string.send_google_result_share_url), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
startShareUrlActivity(shareUrl); startShareUrlActivity(shareUrl);
@@ -171,9 +168,6 @@ public class UploadResultActivity extends Activity {
}); });
} }
return builder.create(); return builder.create();
default:
return null;
}
} }
/** /**
@@ -78,8 +78,9 @@ public class UploadServiceChooserActivity extends Activity {
@Override @Override
protected Dialog onCreateDialog(int id) { protected Dialog onCreateDialog(int id) {
switch (id) { if (id != DIALOG_CHOOSER_ID) {
case DIALOG_CHOOSER_ID: return null;
}
View view = getLayoutInflater().inflate(R.layout.upload_service_chooser, null); View view = getLayoutInflater().inflate(R.layout.upload_service_chooser, null);
mapsTableRow = (TableRow) view.findViewById(R.id.send_google_maps_row); mapsTableRow = (TableRow) view.findViewById(R.id.send_google_maps_row);
@@ -127,8 +128,7 @@ public class UploadServiceChooserActivity extends Activity {
finish(); finish();
} }
}) })
.setPositiveButton( .setPositiveButton(R.string.send_google_send_now, new DialogInterface.OnClickListener() {
R.string.send_google_send_now, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
@@ -146,9 +146,6 @@ public class UploadServiceChooserActivity extends Activity {
.setView(view) .setView(view)
.create(); .create();
return alertDialog; return alertDialog;
default:
return null;
}
} }
/** /**
@@ -37,15 +37,15 @@ public class DialogUtils {
* Creates a confirmation dialog. * Creates a confirmation dialog.
* *
* @param context the context * @param context the context
* @param message the confirmation message * @param messageId the confirmation message id
* @param onClickListener the listener to invoke when the user clicks OK * @param onClickListener the listener to invoke when the user clicks OK
*/ */
public static Dialog createConfirmationDialog( public static Dialog createConfirmationDialog(
Context context, String message, DialogInterface.OnClickListener onClickListener) { Context context, int messageId, DialogInterface.OnClickListener onClickListener) {
return new AlertDialog.Builder(context) return new AlertDialog.Builder(context)
.setCancelable(true) .setCancelable(true)
.setIcon(android.R.drawable.ic_dialog_alert) .setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(message) .setMessage(context.getString(messageId))
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, onClickListener) .setPositiveButton(android.R.string.ok, onClickListener)
.setTitle(R.string.generic_confirm_title) .setTitle(R.string.generic_confirm_title)
@@ -56,38 +56,46 @@ public class DialogUtils {
* Creates a spinner progress dialog. * Creates a spinner progress dialog.
* *
* @param context the context * @param context the context
* @param message the progress message * @param messageId the progress message id
* @param onCancelListener the listener to invoke when the user cancels * @param onCancelListener the cancel listener
*/ */
public static ProgressDialog createSpinnerProgressDialog( public static ProgressDialog createSpinnerProgressDialog(
Context context, String message, DialogInterface.OnCancelListener onCancelListener) { Context context, int messageId, DialogInterface.OnCancelListener onCancelListener) {
ProgressDialog progressDialog = new ProgressDialog(context); return createProgressDialog(true, context, messageId, onCancelListener);
progressDialog.setCancelable(true);
progressDialog.setIcon(android.R.drawable.ic_dialog_info);
progressDialog.setIndeterminate(true);
progressDialog.setMessage(message);
progressDialog.setOnCancelListener(onCancelListener);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setTitle(R.string.generic_progress_title);
return progressDialog;
} }
/** /**
* Creates a horizontal progress dialog. * Creates a horizontal progress dialog.
* *
* @param context the context * @param context the context
* @param message the progress message * @param messageId the progress message id
* @param onCancelListener the listener to invoke when the user cancels * @param onCancelListener the cancel listener
* @param formatArgs the format arguments for the messageId
*/ */
public static ProgressDialog createHorizontalProgressDialog( public static ProgressDialog createHorizontalProgressDialog(Context context, int messageId,
Context context, String message, DialogInterface.OnCancelListener onCancelListener) { DialogInterface.OnCancelListener onCancelListener, Object... formatArgs) {
return createProgressDialog(false, context, messageId, onCancelListener, formatArgs);
}
/**
* Creates a progress dialog.
*
* @param spinner true to use the spinner style
* @param context the context
* @param messageId the progress message id
* @param onCancelListener the cancel listener
* @param formatArgs the format arguments for the message id
*/
private static ProgressDialog createProgressDialog(boolean spinner, Context context,
int messageId, DialogInterface.OnCancelListener onCancelListener, Object... formatArgs) {
ProgressDialog progressDialog = new ProgressDialog(context); ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.setCancelable(true); progressDialog.setCancelable(true);
progressDialog.setIcon(android.R.drawable.ic_dialog_info); progressDialog.setIcon(android.R.drawable.ic_dialog_info);
progressDialog.setIndeterminate(true); progressDialog.setIndeterminate(true);
progressDialog.setMessage(message); progressDialog.setMessage(context.getString(messageId, formatArgs));
progressDialog.setOnCancelListener(onCancelListener); progressDialog.setOnCancelListener(onCancelListener);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setProgressStyle(spinner ? ProgressDialog.STYLE_SPINNER
: ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setTitle(R.string.generic_progress_title); progressDialog.setTitle(R.string.generic_progress_title);
return progressDialog; return progressDialog;
} }
@@ -24,7 +24,6 @@ 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;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
@@ -96,7 +95,7 @@ public class PlayTrackUtils {
.setCancelable(true) .setCancelable(true)
.setMessage(R.string.track_list_play_install_earth_message) .setMessage(R.string.track_list_play_install_earth_message)
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, new OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(); Intent intent = new Intent();
+1
View File
@@ -4,5 +4,6 @@
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/> <classpathentry kind="src" path="gen"/>
<classpathentry exported="true" kind="lib" path="libs/protobuf-java-2.3.0-lite.jar"/> <classpathentry exported="true" kind="lib" path="libs/protobuf-java-2.3.0-lite.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/> <classpathentry kind="output" path="bin/classes"/>
</classpath> </classpath>
+1
View File
@@ -11,5 +11,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/MyTracks"/> <classpathentry combineaccessrules="false" kind="src" path="/MyTracks"/>
<classpathentry kind="lib" path="libs/AndroidMockGenerator.jar"/> <classpathentry kind="lib" path="libs/AndroidMockGenerator.jar"/>
<classpathentry kind="lib" path="libs/robotium-solo-3.1.jar"/> <classpathentry kind="lib" path="libs/robotium-solo-3.1.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/> <classpathentry kind="output" path="bin/classes"/>
</classpath> </classpath>