merge heads

This commit is contained in:
Jimmy Shih
2012-04-11 10:13:01 -07:00
11 changed files with 165 additions and 140 deletions
+1 -12
View File
@@ -193,18 +193,7 @@ limitations under the License.
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="com.google.android.apps.mytracks.TrackDetailActivity" /> <activity android:name="com.google.android.apps.mytracks.TrackDetailActivity" />
<activity <activity android:name="com.google.android.apps.mytracks.TrackEditActivity" />
android:label="@string/track_edit_title"
android:name="com.google.android.apps.mytracks.TrackEditActivity" >
<intent-filter>
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.google.track" />
</intent-filter>
</activity>
<activity android:name="com.google.android.apps.mytracks.TrackListActivity" > <activity android:name="com.google.android.apps.mytracks.TrackListActivity" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@@ -0,0 +1,26 @@
<?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.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<Button
android:id="@+id/track_edit_cancel"
android:text="@string/generic_cancel"
style="@style/BottomButton" />
<Button
android:id="@+id/track_edit_save"
android:text="@string/generic_save"
style="@style/BottomButton" />
</merge>
+1 -1
View File
@@ -24,7 +24,7 @@ limitations under the License.
android:layout_width="fill_parent" > android:layout_width="fill_parent" >
<include layout="@layout/welcome" /> <include layout="@layout/welcome" />
</ScrollView> </ScrollView>
<LinearLayout style="@style/BottomBar" > <LinearLayout style="@style/BottomButtonBar" >
<include layout="@layout/help_buttons" /> <include layout="@layout/help_buttons" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
@@ -486,7 +486,7 @@ limitations under the License.
</TableLayout> </TableLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
<LinearLayout style="@style/BottomBar" > <LinearLayout style="@style/BottomButtonBar" >
<Button <Button
android:id="@+id/waypointdetails_save" android:id="@+id/waypointdetails_save"
android:text="@string/generic_save" android:text="@string/generic_save"
@@ -39,7 +39,7 @@ limitations under the License.
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"/> android:layout_weight="1"/>
<LinearLayout style="@style/BottomBar" > <LinearLayout style="@style/BottomButtonBar" >
<Button <Button
android:id="@+id/waypointslist_btn_insert_statistics" android:id="@+id/waypointslist_btn_insert_statistics"
android:text="@string/marker_list_insert_statistics" android:text="@string/marker_list_insert_statistics"
+36 -73
View File
@@ -14,92 +14,55 @@ 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 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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" android:orientation="vertical" >
>
<ScrollView <ScrollView
android:background="@color/black"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_width="fill_parent" android:layout_width="fill_parent" >
> <LinearLayout
<LinearLayout
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:orientation="vertical" android:orientation="vertical"
android:padding="4dp" android:padding="8dp" >
>
<TextView <TextView
android:layout_height="wrap_content" android:text="@string/track_edit_name"
android:layout_width="fill_parent" style="@style/TrackEditLabelTextView" />
android:text="@string/track_edit_track_name"
/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal"
>
<ImageView
android:contentDescription="@string/track_icon_description"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:src="@drawable/track"
/>
<EditText
android:inputType="textAutoCorrect|textCapWords"
android:hint="@string/track_edit_track_name"
android:id="@+id/track_edit_track_name"
android:imeOptions="actionNext"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:selectAllOnFocus="true"
android:singleLine="true"
/>
</LinearLayout>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="@string/track_edit_activity_type"
/>
<AutoCompleteTextView
android:id="@+id/track_edit_activity_type"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="@string/track_edit_activity_type_hint"
android:imeOptions="actionNext"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="@string/track_edit_track_description"
/>
<EditText <EditText
android:inputType="textAutoCorrect|textCapSentences" android:drawableLeft="@drawable/track"
android:hint="@string/track_edit_track_description" android:drawablePadding="8dp"
android:id="@+id/track_edit_track_description" android:gravity="center_vertical"
android:hint="@string/track_edit_name"
android:id="@+id/track_edit_name"
android:imeOptions="actionNext"
android:inputType="textAutoCorrect|textCapWords"
android:singleLine="true"
style="@style/TrackEditValueEditText" />
<TextView
android:text="@string/track_edit_activity_type"
style="@style/TrackEditLabelTextView" />
<AutoCompleteTextView
android:hint="@string/track_edit_activity_type_hint"
android:id="@+id/track_edit_activity_type"
android:imeOptions="actionNext"
android:singleLine="true"
style="@style/TrackEditValueEditText" />
<TextView
android:text="@string/track_edit_description"
style="@style/TrackEditLabelTextView" />
<EditText
android:hint="@string/track_edit_description"
android:id="@+id/track_edit_description"
android:imeOptions="actionDone" android:imeOptions="actionDone"
android:layout_height="wrap_content" android:inputType="textAutoCorrect|textCapSentences"
android:layout_width="fill_parent"
android:maxLines="50" android:maxLines="50"
android:selectAllOnFocus="true"
android:singleLine="false" android:singleLine="false"
/> style="@style/TrackEditValueEditText" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
<LinearLayout style="@style/BottomBar" > <LinearLayout style="@style/BottomButtonBar" >
<Button <include layout="@layout/track_edit_buttons" />
android:id="@+id/track_edit_save"
android:text="@string/generic_save"
style="@style/BottomButton" />
<Button
android:id="@+id/track_edit_cancel"
android:text="@string/generic_cancel"
style="@style/BottomButton" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
@@ -0,0 +1,26 @@
<?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.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<Button
android:id="@+id/track_edit_save"
android:text="@string/generic_save"
style="@style/BottomButton" />
<Button
android:id="@+id/track_edit_cancel"
android:text="@string/generic_cancel"
style="@style/BottomButton" />
</merge>
+12 -12
View File
@@ -2193,28 +2193,28 @@ limitations under the License.
Track Track
</string> </string>
<string name="track_edit_activity_type" <string name="track_edit_activity_type"
translation_description="In the page to edit a track, the title for the text field to edit the translation_description="In the page to edit a track, the label for the text field to edit the
activity type, including some examples of activity types."> activity type, including some examples of activity types.">
Activity type (e.g. hiking, cycling, running...) Activity type (e.g. hiking, cycling...)
</string> </string>
<string name="track_edit_activity_type_hint" <string name="track_edit_activity_type_hint"
translation_description="In the page to edit a track, the hint in the 'Activity type' text field translation_description="In the page to edit a track, the hint in the 'Activity type' text field
when it is empty."> when it is empty.">
Activity type Activity type
</string> </string>
<string name="track_edit_title" <string name="track_edit_description"
translation_description="The title of the page to edit a track."> translation_description="In the page to edit a track, the label for the text field to edit the
Edit track
</string>
<string name="track_edit_track_description"
translation_description="In the page to edit a track, the title for the text field to edit the
track description."> track description.">
Track description Description
</string> </string>
<string name="track_edit_track_name" <string name="track_edit_name"
translation_description="In the page to edit a track, the title for the text field to edit the translation_description="In the page to edit a track, the label for the text field to edit the
track name."> track name.">
Track name Name
</string>
<string name="track_edit_new_track_title"
translation_description="The title of the track edit page when saving a new track.">
New Track
</string> </string>
<string name="track_list_delete_all_confirm_message" <string name="track_list_delete_all_confirm_message"
translation_description="When deleting all the tracks, the confirmation dialog message informing translation_description="When deleting all the tracks, the confirmation dialog message informing
+18 -8
View File
@@ -17,14 +17,13 @@ limitations under the License.
<resources> <resources>
<style name="ThemeSelector" parent="android:Theme" /> <style name="ThemeSelector" parent="android:Theme" />
<!-- Bottom Bar --> <!-- The style for the bottom button bar -->
<style name="BottomBar" parent="@android:style/DeviceDefault.ButtonBar"> <style name="BottomButtonBar" parent="@android:style/DeviceDefault.ButtonBar">
<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>
<item name="android:orientation">horizontal</item> <item name="android:orientation">horizontal</item>
</style> </style>
<!-- The style for the bottom button -->
<!-- Bottom Button -->
<style name="BottomButton" parent="@android:style/Widget.DeviceDefault.Button.Borderless"> <style name="BottomButton" parent="@android:style/Widget.DeviceDefault.Button.Borderless">
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item> <item name="android:layout_weight">1</item>
@@ -109,7 +108,19 @@ limitations under the License.
<item name="android:textColor">@color/stat_label_text</item> <item name="android:textColor">@color/stat_label_text</item>
</style> </style>
<!-- The TextView showing the stats in the track list item --> <!-- The style for the label in track_edit.xml -->
<style name="TrackEditLabelTextView" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
</style>
<!-- The style for the value in track_edit.xml -->
<style name="TrackEditValueEditText" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:selectAllOnFocus">true</item>
</style>
<!-- The style for the stats in track_list_item.xml -->
<style name="TrackListItemStatsTextView" parent="@android:style/TextAppearance.DeviceDefault.Small"> <style name="TrackListItemStatsTextView" parent="@android:style/TextAppearance.DeviceDefault.Small">
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item> <item name="android:layout_width">wrap_content</item>
@@ -117,14 +128,13 @@ limitations under the License.
<item name="android:textColor">@color/green</item> <item name="android:textColor">@color/green</item>
</style> </style>
<!-- The welcome activity answer TextView --> <!-- The style for the answer in welcome.xml -->
<style name="WelcomeAnswerTextView" parent="@android:style/TextAppearance.DeviceDefault.Small"> <style name="WelcomeAnswerTextView" parent="@android:style/TextAppearance.DeviceDefault.Small">
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item> <item name="android:layout_width">wrap_content</item>
<item name="android:paddingBottom">8dp</item> <item name="android:paddingBottom">8dp</item>
</style> </style>
<!-- The style for the question in welcome.xml -->
<!-- The welcome activity question TextView -->
<style name="WelcomeQuestionTextView" parent="@android:style/TextAppearance.DeviceDefault.Medium"> <style name="WelcomeQuestionTextView" parent="@android:style/TextAppearance.DeviceDefault.Medium">
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item> <item name="android:layout_width">wrap_content</item>
@@ -13,15 +13,19 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.google.android.apps.mytracks; package com.google.android.apps.mytracks;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.maps.mytracks.R; import com.google.android.maps.mytracks.R;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.util.Log; import android.util.Log;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@@ -32,7 +36,7 @@ import android.widget.EditText;
/** /**
* An activity that let's the user see and edit the user editable track meta * An activity that let's the user see and edit the user editable track meta
* data such as track name, activity type, and track description. * data such as track name, activity type, and track description.
* *
* @author Leif Hendrik Wilden * @author Leif Hendrik Wilden
*/ */
public class TrackEditActivity extends Activity implements OnClickListener { public class TrackEditActivity extends Activity implements OnClickListener {
@@ -46,33 +50,34 @@ public class TrackEditActivity extends Activity implements OnClickListener {
private MyTracksProviderUtils myTracksProviderUtils; private MyTracksProviderUtils myTracksProviderUtils;
private Track track; private Track track;
private EditText trackName; private EditText name;
private AutoCompleteTextView activityType; private AutoCompleteTextView activityType;
private EditText trackDescription; private EditText description;
@Override @Override
protected void onCreate(Bundle bundle) { protected void onCreate(Bundle bundle) {
super.onCreate(bundle); super.onCreate(bundle);
setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
ApiAdapterFactory.getApiAdapter().configureActionBarHomeAsUp(this);
setContentView(R.layout.track_edit); setContentView(R.layout.track_edit);
trackId = getIntent().getLongExtra(EXTRA_TRACK_ID, -1); trackId = getIntent().getLongExtra(EXTRA_TRACK_ID, -1L);
if (trackId < 0) { if (trackId == -1L) {
Log.e(TAG, "invalid trackId."); Log.e(TAG, "invalid trackId");
finish(); finish();
return; return;
} }
myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this); myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this);
track = myTracksProviderUtils.getTrack(trackId); track = myTracksProviderUtils.getTrack(trackId);
if (track == null) { if (track == null) {
Log.e(TAG, "no track."); Log.e(TAG, "no track");
finish(); finish();
return; return;
} }
trackName = (EditText) findViewById(R.id.track_edit_track_name); name = (EditText) findViewById(R.id.track_edit_name);
trackName.setText(track.getName()); name.setText(track.getName());
activityType = (AutoCompleteTextView) findViewById(R.id.track_edit_activity_type); activityType = (AutoCompleteTextView) findViewById(R.id.track_edit_activity_type);
activityType.setText(track.getCategory()); activityType.setText(track.getCategory());
@@ -80,40 +85,40 @@ public class TrackEditActivity extends Activity implements OnClickListener {
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.activity_types, android.R.layout.simple_dropdown_item_1line); this, R.array.activity_types, android.R.layout.simple_dropdown_item_1line);
activityType.setAdapter(adapter); activityType.setAdapter(adapter);
trackDescription = (EditText) findViewById(R.id.track_edit_track_description); description = (EditText) findViewById(R.id.track_edit_description);
trackDescription.setText(track.getDescription()); description.setText(track.getDescription());
Button save = (Button) findViewById(R.id.track_edit_save); Button save = (Button) findViewById(R.id.track_edit_save);
save.setOnClickListener(this); save.setOnClickListener(this);
Button cancel = (Button) findViewById(R.id.track_edit_cancel); Button cancel = (Button) findViewById(R.id.track_edit_cancel);
if (getIntent().getBooleanExtra(EXTRA_SHOW_CANCEL, true)) { if (getIntent().getBooleanExtra(EXTRA_SHOW_CANCEL, true)) {
setTitle(R.string.menu_edit);
cancel.setOnClickListener(this); cancel.setOnClickListener(this);
cancel.setVisibility(View.VISIBLE); cancel.setVisibility(View.VISIBLE);
} else { } else {
cancel.setVisibility(View.INVISIBLE); setTitle(R.string.track_edit_new_track_title);
cancel.setVisibility(View.GONE);
} }
} }
@Override @Override
public void onClick(View view) { public boolean onOptionsItemSelected(MenuItem item) {
switch (view.getId()) { if (item.getItemId() != android.R.id.home) {
case R.id.track_edit_save: return false;
save();
finish();
break;
case R.id.track_edit_cancel:
finish();
break;
default:
finish();
} }
finish();
return true;
} }
private void save() { @Override
track.setName(trackName.getText().toString()); public void onClick(View view) {
track.setCategory(activityType.getText().toString()); if (view.getId() == R.id.track_edit_save) {
track.setDescription(trackDescription.getText().toString()); track.setName(name.getText().toString());
myTracksProviderUtils.updateTrack(track); track.setCategory(activityType.getText().toString());
track.setDescription(description.getText().toString());
myTracksProviderUtils.updateTrack(track);
}
finish();
} }
} }
@@ -387,14 +387,20 @@ public class TrackListActivity extends FragmentActivity {
ITrackRecordingService service = trackRecordingServiceConnection.getServiceIfBound(); ITrackRecordingService service = trackRecordingServiceConnection.getServiceIfBound();
if (service != null) { if (service != null) {
try { try {
/*
* Remembers the recordingTrackId before endCurrentTrack sets the shared
* preferences, R.string.recording_track_key, to -1L, and the
* sharedPreferenceChangedListener sets the recordingTrackId variable to
* -1L.
*/
long trackId = recordingTrackId;
service.endCurrentTrack(); service.endCurrentTrack();
if (recordingTrackId != -1L) { if (trackId != -1L) {
Intent intent = new Intent(this, TrackEditActivity.class) Intent intent = new Intent(this, TrackEditActivity.class)
.putExtra(TrackEditActivity.EXTRA_SHOW_CANCEL, false) .putExtra(TrackEditActivity.EXTRA_SHOW_CANCEL, false)
.putExtra(TrackEditActivity.EXTRA_TRACK_ID, recordingTrackId); .putExtra(TrackEditActivity.EXTRA_TRACK_ID, trackId);
startActivity(intent); startActivity(intent);
} }
recordingTrackId = -1L;
} catch (Exception e) { } catch (Exception e) {
Log.d(TAG, "Unable to stop recording.", e); Log.d(TAG, "Unable to stop recording.", e);
} }