Providing a Search menu option in TrackList and WaypointList, for devices that don't have a search key.

This commit is contained in:
Rodrigo Damazio
2012-01-05 22:17:31 -02:00
parent 254a1d59ac
commit 870c5d723c
5 changed files with 66 additions and 7 deletions
+1 -4
View File
@@ -153,18 +153,15 @@ limitations under the License.
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale"
android:exported="false" /> android:exported="false" />
<!-- TODO: VIEW and PICK for track cursor dir --> <!-- TODO: Merge TrackList, WaypointsLIst and SearchActivity, then implement VIEW and PICK for track and waypoint cursor dir -->
<activity android:name="com.google.android.apps.mytracks.TrackList"> <activity android:name="com.google.android.apps.mytracks.TrackList">
<!-- Enable searches via SearchActivity. --> <!-- Enable searches via SearchActivity. -->
<!-- TODO: Provide a UI for devices without a search key. -->
<meta-data android:name="android.app.default_searchable" <meta-data android:name="android.app.default_searchable"
android:value="com.google.android.apps.mytracks.SearchActivity" /> android:value="com.google.android.apps.mytracks.SearchActivity" />
</activity> </activity>
<!-- TODO: VIEW and PICK for waypoint cursor dir -->
<activity android:name="com.google.android.apps.mytracks.WaypointsList"> <activity android:name="com.google.android.apps.mytracks.WaypointsList">
<!-- Enable searches via SearchActivity. --> <!-- Enable searches via SearchActivity. -->
<!-- TODO: Provide a UI for devices without a search key. -->
<meta-data android:name="android.app.default_searchable" <meta-data android:name="android.app.default_searchable"
android:value="com.google.android.apps.mytracks.SearchActivity" /> android:value="com.google.android.apps.mytracks.SearchActivity" />
</activity> </activity>
+15
View File
@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_record_track" <item android:id="@+id/menu_record_track"
android:icon="@drawable/ic_menu_recordtrack" android:icon="@drawable/ic_menu_recordtrack"
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2012 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.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/menu_search"
android:icon="@android:drawable/ic_menu_search"
android:title="@string/menu_search"
android:onClick="onSearch"
android:showAsAction="always" />
</menu>
@@ -38,6 +38,7 @@ import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.SubMenu; import android.view.SubMenu;
import android.view.View; import android.view.View;
@@ -90,7 +91,7 @@ public class TrackList extends ListActivity
String saveFileFormat = getString(R.string.track_list_save_file); String saveFileFormat = getString(R.string.track_list_save_file);
String shareFileFormat = getString(R.string.track_list_share_file); String shareFileFormat = getString(R.string.track_list_share_file);
String fileTypes[] = getResources().getStringArray(R.array.file_types); String fileTypes[] = getResources().getStringArray(R.array.file_types);
menu.add(0, Constants.MENU_SEND_TO_GOOGLE, 0, menu.add(0, Constants.MENU_SEND_TO_GOOGLE, 0,
R.string.track_list_send_google); R.string.track_list_send_google);
SubMenu share = menu.addSubMenu(0, Constants.MENU_SHARE, 0, SubMenu share = menu.addSubMenu(0, Constants.MENU_SHARE, 0,
@@ -275,6 +276,17 @@ public class TrackList extends ListActivity
super.onDestroy(); super.onDestroy();
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_only, menu);
return true;
}
/* Callback from menu/search_only.xml */
public void onSearch(@SuppressWarnings("unused") MenuItem i) {
onSearchRequested();
}
private void updateButtonsEnabled() { private void updateButtonsEnabled() {
View deleteAll = findViewById(R.id.tracklist_btn_delete_all); View deleteAll = findViewById(R.id.tracklist_btn_delete_all);
View exportAll = findViewById(R.id.tracklist_btn_export_all); View exportAll = findViewById(R.id.tracklist_btn_export_all);
@@ -38,6 +38,7 @@ import android.os.RemoteException;
import android.util.Log; import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnCreateContextMenuListener; import android.view.View.OnCreateContextMenuListener;
@@ -197,6 +198,17 @@ public class WaypointsList extends ListActivity
super.onDestroy(); super.onDestroy();
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_only, menu);
return true;
}
/* Callback from menu/search_only.xml */
public void onSearch(@SuppressWarnings("unused") MenuItem i) {
onSearchRequested();
}
@Override @Override
public void onClick(View v) { public void onClick(View v) {
WaypointCreationRequest request; WaypointCreationRequest request;
@@ -265,10 +277,10 @@ public class WaypointsList extends ListActivity
if (columnIndex == timeIdx) { if (columnIndex == timeIdx) {
long time = cursor.getLong(timeIdx); long time = cursor.getLong(timeIdx);
TextView textView = (TextView) view; TextView textView = (TextView) view;
if (time == 0) { if (time == 0) {
textView.setVisibility(View.GONE); textView.setVisibility(View.GONE);
} else { } else {
textView.setText(StringUtils.formatDateTime(time)); textView.setText(StringUtils.formatDateTime(time));
textView.setVisibility(View.VISIBLE); textView.setVisibility(View.VISIBLE);
} }