Hide menu items when track list is empty

This commit is contained in:
Jimmy Shih
2013-12-18 16:10:25 -08:00
parent a49a74fc6b
commit 3b5b2461bb
4 changed files with 17 additions and 33 deletions
-10
View File
@@ -632,16 +632,6 @@ limitations under the License.
%2$s the directory. E.g., '/MyTracks/kml'.">
Exported %1$d of %2$s to %3$s.
</string>
<string name="export_external_storage_no_track"
translation_description="When exporting tracks to the external storage, the message in the
result dialog when there is no tracks to export.">
There is no tracks to export.
</string>
<string name="export_external_storage_no_track_title"
translation_description="When exporting tracks to the external storage, the title in the result
dialog when there is no tracks to export.">
Export tracks
</string>
<string name="export_external_storage_option"
translation_description="When exporting a track to the external storage, the option to export as
a certain file format.
@@ -307,7 +307,9 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
// Menu items
private MenuItem searchMenuItem;
private MenuItem startGpsMenuItem;
private MenuItem playMultipleItem;
private MenuItem syncNowMenuItem;
private MenuItem aggregatedStatisticsMenuItem;
private MenuItem exportAllMenuItem;
private MenuItem importAllMenuItem;
private MenuItem deleteAllMenuItem;
@@ -469,7 +471,9 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
ApiAdapterFactory.getApiAdapter().configureSearchWidget(this, searchMenuItem, trackController);
startGpsMenuItem = menu.findItem(R.id.track_list_start_gps);
playMultipleItem = menu.findItem(R.id.track_list_play_mutliple);
syncNowMenuItem = menu.findItem(R.id.track_list_sync_now);
aggregatedStatisticsMenuItem = menu.findItem(R.id.track_list_aggregated_statistics);
exportAllMenuItem = menu.findItem(R.id.track_list_export_all);
importAllMenuItem = menu.findItem(R.id.track_list_import_all);
deleteAllMenuItem = menu.findItem(R.id.track_list_delete_all);
@@ -730,6 +734,7 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
* @param isRecording true if recording
*/
private void updateMenuItems(boolean isGpsStarted, boolean isRecording) {
boolean hasTrack = listView != null && listView.getCount() != 0;
if (startGpsMenuItem != null) {
startGpsMenuItem.setVisible(!isRecording);
if (!isRecording) {
@@ -739,17 +744,23 @@ public class TrackListActivity extends AbstractSendToGoogleActivity
TrackIconUtils.setMenuIconColor(startGpsMenuItem);
}
}
if (playMultipleItem != null) {
playMultipleItem.setVisible(hasTrack);
}
if (syncNowMenuItem != null) {
syncNowMenuItem.setTitle(driveSync ? R.string.menu_sync_now : R.string.menu_sync_drive);
}
if (aggregatedStatisticsMenuItem != null) {
aggregatedStatisticsMenuItem.setVisible(hasTrack);
}
if (exportAllMenuItem != null) {
exportAllMenuItem.setVisible(!isRecording);
exportAllMenuItem.setVisible(hasTrack && !isRecording);
}
if (importAllMenuItem != null) {
importAllMenuItem.setVisible(!isRecording);
}
if (deleteAllMenuItem != null) {
deleteAllMenuItem.setVisible(!isRecording);
deleteAllMenuItem.setVisible(hasTrack && !isRecording);
}
}
@@ -135,16 +135,10 @@ public class SaveActivity extends Activity {
String totalTracks = getResources()
.getQuantityString(R.plurals.tracks, totalCount, totalCount);
if (successCount == totalCount) {
if (totalCount == 0) {
iconId = android.R.drawable.ic_dialog_info;
titleId = R.string.export_external_storage_no_track_title;
message = getString(R.string.export_external_storage_no_track);
} else {
iconId = R.drawable.ic_dialog_success;
titleId = R.string.generic_success_title;
message = getString(
R.string.export_external_storage_success, totalTracks, directoryDisplayName);
}
iconId = R.drawable.ic_dialog_success;
titleId = R.string.generic_success_title;
message = getString(
R.string.export_external_storage_success, totalTracks, directoryDisplayName);
} else {
iconId = android.R.drawable.ic_dialog_alert;
titleId = R.string.generic_error_title;
@@ -71,17 +71,6 @@ public class DeleteTest extends ActivityInstrumentationTestCase2<TrackListActivi
// There is no track now.
trackListView = EndToEndTestUtils.SOLO.getCurrentViews(ListView.class);
assertEquals(0, trackListView.get(0).getCount());
// Export when there is no track.
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_export_all), true);
EndToEndTestUtils.SOLO.clickOnText(EndToEndTestUtils.GPX.toUpperCase());
EndToEndTestUtils
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
EndToEndTestUtils.waitTextToDisappear(activityMyTracks
.getString(R.string.generic_progress_title));
assertTrue(EndToEndTestUtils.SOLO.waitForText(activityMyTracks
.getString(R.string.export_external_storage_no_track)));
EndToEndTestUtils
.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, true);
}
/**