diff --git a/MyTracks/src/com/google/android/apps/mytracks/AccountChooser.java b/MyTracks/src/com/google/android/apps/mytracks/AccountChooser.java index c26434440..9f1ae3263 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/AccountChooser.java +++ b/MyTracks/src/com/google/android/apps/mytracks/AccountChooser.java @@ -1,12 +1,12 @@ /* * Copyright 2010 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 @@ -52,7 +52,7 @@ public class AccountChooser { * If no account is found the user will be alerted. * If only one account is found that will be used. * If multiple accounts are found the user will be allowed to choose. - * + * * @param activity The parent activity * @param handler The handler to be notified when an account has been selected */ @@ -83,13 +83,18 @@ public class AccountChooser { builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { - selectedAccount = accounts[selectedAccountIndex]; + dialog.dismiss(); + + if (selectedAccountIndex >= 0) { + selectedAccount = accounts[selectedAccountIndex]; + } handler.handleAccountSelected(selectedAccount); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); handler.handleAccountSelected(null); } }); @@ -120,6 +125,7 @@ public class AccountChooser { builder.setNegativeButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); handler.handleAccountSelected(null); } }); diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyMapsList.java b/MyTracks/src/com/google/android/apps/mytracks/MyMapsList.java index 0ee852e29..3e3f0096c 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MyMapsList.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MyMapsList.java @@ -1,12 +1,12 @@ /* * 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 @@ -90,6 +90,8 @@ public class MyMapsList extends Activity implements MapsFacade.MapsListCallback // The user did not quit and there was a valid google // account. doLogin(account); + } else { + finish(); } } }); diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendActivity.java b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendActivity.java index 84d08bc26..9b4728e61 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/sendtogoogle/SendActivity.java @@ -112,6 +112,7 @@ public class SendActivity extends Activity implements ProgressIndicator { @Override protected void onStart() { + Log.d(TAG, "SendActivity.onStart"); super.onStart(); resetState(); @@ -152,6 +153,7 @@ public class SendActivity extends Activity implements ProgressIndicator { @Override protected void onStop() { + Log.d(TAG, "SendActivity.onStop"); tracker.dispatch(); tracker.stop(); @@ -403,18 +405,27 @@ public class SendActivity extends Activity implements ProgressIndicator { final boolean canShare = sendToFusionTablesTableId != null || sendToMyMapsMapId != null; + final OnClickListener finishListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + finish(); + } + }; + DialogInterface.OnClickListener doShareListener = null; if (canShare) { doShareListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { shareLinkToMap(sentToMyMaps, sentToFusionTables); + finishListener.onClick(dialog, which); } }; } DialogInterface.OnClickListener onOkListener = (canShare && shareRequested) - ? doShareListener : null; + ? doShareListener : finishListener; DialogInterface.OnClickListener onShareListener = (canShare && !shareRequested) ? doShareListener : null; @@ -523,7 +534,8 @@ public class SendActivity extends Activity implements ProgressIndicator { public void handleAccountSelected(Account account) { if (account == null) { progressDialog.dismiss(); - return; + progressDialog = null; + finish(); } doLogin(results, requestCode, service, account); @@ -533,9 +545,10 @@ public class SendActivity extends Activity implements ProgressIndicator { private void doLogin(final Intent results, final int requestCode, final String service, final Account account) { + // There's a chance that we go to a different activity, so close the dialog. lastAuth.doLogin(new Runnable() { public void run() { - Log.i(TAG, "Loggin success for " + service + "!"); + Log.i(TAG, "Login success for " + service + "!"); onActivityResult(requestCode, RESULT_OK, results); } }, account);