From 7701d31bdcb1c1f17434c30a532298445172f233 Mon Sep 17 00:00:00 2001 From: Jimmy Shih Date: Fri, 20 Apr 2012 17:46:48 -0700 Subject: [PATCH] Clean up all the layouts. Utilize styles when possible. --- MyTracks/res/drawable/list_bar.xml | 19 --- MyTracks/res/layout/about.xml | 57 ++----- MyTracks/res/layout/chart.xml | 35 +++++ MyTracks/res/layout/chart_settings.xml | 73 +++------ MyTracks/res/layout/choose_map.xml | 29 +--- MyTracks/res/layout/choose_map_item.xml | 38 ++--- MyTracks/res/layout/help.xml | 7 +- MyTracks/res/layout/list_item.xml | 11 +- MyTracks/res/layout/map.xml | 37 +++++ MyTracks/res/layout/marker_detail.xml | 10 +- MyTracks/res/layout/marker_edit.xml | 17 +- MyTracks/res/layout/marker_list.xml | 4 +- MyTracks/res/layout/mytracks_charts.xml | 57 ------- MyTracks/res/layout/mytracks_layout.xml | 62 -------- MyTracks/res/layout/search_list.xml | 4 +- MyTracks/res/layout/sensor_state.xml | 12 +- MyTracks/res/layout/track_edit.xml | 11 +- MyTracks/res/layout/track_list.xml | 6 +- MyTracks/res/layout/track_widget.xml | 126 +++++++-------- MyTracks/res/layout/upload_result.xml | 42 ++--- .../res/layout/upload_service_chooser.xml | 46 ++---- MyTracks/res/layout/welcome.xml | 5 +- MyTracks/res/values/strings.xml | 9 +- MyTracks/res/values/styles.xml | 146 ++++++++---------- .../apps/mytracks/TrackDetailActivity.java | 2 +- .../mytracks/fragments/ChartFragment.java | 19 +-- .../apps/mytracks/fragments/MapFragment.java | 32 ++-- .../mytracks/io/maps/ChooseMapActivity.java | 6 +- 28 files changed, 340 insertions(+), 582 deletions(-) delete mode 100644 MyTracks/res/drawable/list_bar.xml create mode 100644 MyTracks/res/layout/chart.xml create mode 100644 MyTracks/res/layout/map.xml delete mode 100644 MyTracks/res/layout/mytracks_charts.xml delete mode 100644 MyTracks/res/layout/mytracks_layout.xml diff --git a/MyTracks/res/drawable/list_bar.xml b/MyTracks/res/drawable/list_bar.xml deleted file mode 100644 index 82add4723..000000000 --- a/MyTracks/res/drawable/list_bar.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - diff --git a/MyTracks/res/layout/about.xml b/MyTracks/res/layout/about.xml index 4e73b7c0e..b087fe596 100644 --- a/MyTracks/res/layout/about.xml +++ b/MyTracks/res/layout/about.xml @@ -15,64 +15,35 @@ See the License for the specific language governing permissions and limitations under the License. --> - + style="@style/ScrollView" > - - + android:text="@string/about_copyright_notice" + style="@style/TextMedium.WithIcon" /> - + android:text="@string/about_version" + style="@style/TextLarge" /> - + style="@style/AboutValue" /> - + android:text="@string/about_support" + style="@style/TextLarge" /> - + android:text="@string/my_tracks_support_url" + style="@style/AboutValue" /> - + android:text="@string/about_privacy" + style="@style/TextLarge" /> + android:text="@string/my_tracks_privacy_url" + style="@style/AboutValue" /> - \ No newline at end of file diff --git a/MyTracks/res/layout/chart.xml b/MyTracks/res/layout/chart.xml new file mode 100644 index 000000000..b5d169658 --- /dev/null +++ b/MyTracks/res/layout/chart.xml @@ -0,0 +1,35 @@ + + + + + + + \ No newline at end of file diff --git a/MyTracks/res/layout/chart_settings.xml b/MyTracks/res/layout/chart_settings.xml index e50ae4225..0df6d4eec 100644 --- a/MyTracks/res/layout/chart_settings.xml +++ b/MyTracks/res/layout/chart_settings.xml @@ -15,87 +15,52 @@ See the License for the specific language governing permissions and limitations under the License. --> - + style="@style/ScrollView" > - - + android:text="@string/chart_settings_x_axis" + style="@style/TextLarge.WithIcon" /> - - + android:text="@string/chart_settings_by_distance" + style="@style/TextMedium" /> + android:text="@string/chart_settings_by_time" + style="@style/TextMedium" /> - - + android:text="@string/chart_settings_y_axis" + style="@style/TextLarge.WithIcon" /> - + android:text="@string/stats_elevation" + style="@style/TextMedium" /> - + android:text="@string/stats_speed" + style="@style/TextMedium" /> - + android:text="@string/sensor_state_power" + style="@style/TextMedium" /> - + android:text="@string/sensor_state_cadence" + style="@style/TextMedium" /> + android:text="@string/sensor_state_heart_rate" + style="@style/TextMedium" /> - \ No newline at end of file diff --git a/MyTracks/res/layout/choose_map.xml b/MyTracks/res/layout/choose_map.xml index 13f453177..4f5d00f94 100644 --- a/MyTracks/res/layout/choose_map.xml +++ b/MyTracks/res/layout/choose_map.xml @@ -14,32 +14,15 @@ 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. --> - - + android:layout_width="fill_parent" > + android:layout_width="fill_parent" /> - + style="@style/ListEmptyTextView" > + + diff --git a/MyTracks/res/layout/choose_map_item.xml b/MyTracks/res/layout/choose_map_item.xml index eb27429a1..20da468ef 100644 --- a/MyTracks/res/layout/choose_map_item.xml +++ b/MyTracks/res/layout/choose_map_item.xml @@ -15,33 +15,23 @@ See the License for the specific language governing permissions and limitations under the License. --> + android:padding="8dp" > + android:id="@+id/choose_map_item_title" + android:singleLine="true" + style="@style/TextLarge" /> + android:id="@+id/choose_map_item_description" + android:singleLine="false" + android:textColor="@android:color/secondary_text_dark" + style="@style/TextSmall" /> - + android:id="@+id/choose_map_item_search_status" + android:singleLine="true" + style="@style/TextSmall" /> + \ No newline at end of file diff --git a/MyTracks/res/layout/help.xml b/MyTracks/res/layout/help.xml index dda328b77..cece4ce98 100644 --- a/MyTracks/res/layout/help.xml +++ b/MyTracks/res/layout/help.xml @@ -18,11 +18,8 @@ limitations under the License. android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" > - - + + diff --git a/MyTracks/res/layout/list_item.xml b/MyTracks/res/layout/list_item.xml index bd2eb1ed4..fbe066805 100644 --- a/MyTracks/res/layout/list_item.xml +++ b/MyTracks/res/layout/list_item.xml @@ -27,10 +27,13 @@ limitations under the License. android:orientation="horizontal" > + android:singleLine="true" + style="@style/TextLarge.WithIcon" /> + android:layout_marginLeft="8dp" + android:singleLine="true" + style="@style/TextSmall" /> + android:singleLine="false" + android:textColor="@android:color/secondary_text_dark" + style="@style/TextSmall" /> \ No newline at end of file diff --git a/MyTracks/res/layout/map.xml b/MyTracks/res/layout/map.xml new file mode 100644 index 000000000..7be8cc992 --- /dev/null +++ b/MyTracks/res/layout/map.xml @@ -0,0 +1,37 @@ + + + + + + + \ No newline at end of file diff --git a/MyTracks/res/layout/marker_detail.xml b/MyTracks/res/layout/marker_detail.xml index 66e7a03c1..e297e99f7 100644 --- a/MyTracks/res/layout/marker_detail.xml +++ b/MyTracks/res/layout/marker_detail.xml @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. --> + style="@style/ScrollView" > + style="@style/TextLarge" /> + style="@style/TextLarge" /> + style="@style/TextLarge" /> - + \ No newline at end of file diff --git a/MyTracks/res/layout/marker_edit.xml b/MyTracks/res/layout/marker_edit.xml index 9d3ee22d3..6ad93af0c 100644 --- a/MyTracks/res/layout/marker_edit.xml +++ b/MyTracks/res/layout/marker_edit.xml @@ -18,10 +18,7 @@ limitations under the License. android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" > - + + style="@style/TextMedium" /> + style="@style/TextMedium" /> + style="@style/TextMedium" /> + style="@style/TextMedium" /> + style="@style/TextMedium" /> + style="@style/TextMedium" /> - - \ No newline at end of file + \ No newline at end of file diff --git a/MyTracks/res/layout/mytracks_charts.xml b/MyTracks/res/layout/mytracks_charts.xml deleted file mode 100644 index e015f7676..000000000 --- a/MyTracks/res/layout/mytracks_charts.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - diff --git a/MyTracks/res/layout/mytracks_layout.xml b/MyTracks/res/layout/mytracks_layout.xml deleted file mode 100644 index 20fec4b55..000000000 --- a/MyTracks/res/layout/mytracks_layout.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - diff --git a/MyTracks/res/layout/search_list.xml b/MyTracks/res/layout/search_list.xml index 45a3090af..21995c42c 100644 --- a/MyTracks/res/layout/search_list.xml +++ b/MyTracks/res/layout/search_list.xml @@ -14,7 +14,7 @@ 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. --> - - \ No newline at end of file + \ No newline at end of file diff --git a/MyTracks/res/layout/sensor_state.xml b/MyTracks/res/layout/sensor_state.xml index 63e499a6c..7a4088436 100644 --- a/MyTracks/res/layout/sensor_state.xml +++ b/MyTracks/res/layout/sensor_state.xml @@ -23,42 +23,42 @@ limitations under the License. android:padding="8dp" > + style="@style/TextMedium" /> + style="@style/TextMedium" /> + style="@style/TextMedium" /> + style="@style/TextMedium" /> + style="@style/TextMedium" /> + style="@style/TextMedium" /> diff --git a/MyTracks/res/layout/track_edit.xml b/MyTracks/res/layout/track_edit.xml index 80877293a..8c3364d48 100644 --- a/MyTracks/res/layout/track_edit.xml +++ b/MyTracks/res/layout/track_edit.xml @@ -18,10 +18,7 @@ limitations under the License. android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" > - + + style="@style/TextMedium" /> + style="@style/TextMedium" /> + style="@style/TextMedium" /> - + android:orientation="vertical" > @@ -40,4 +40,4 @@ limitations under the License. android:src="@drawable/menu_record_track" style="@android:style/Widget.DeviceDefault.ImageButton" /> - \ No newline at end of file + \ No newline at end of file diff --git a/MyTracks/res/layout/track_widget.xml b/MyTracks/res/layout/track_widget.xml index 9000dce3d..55ca5bed2 100644 --- a/MyTracks/res/layout/track_widget.xml +++ b/MyTracks/res/layout/track_widget.xml @@ -14,77 +14,71 @@ 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. --> - - - + - + android:layout_width="wrap_content" + android:paddingLeft="10dp" + android:paddingRight="10dp" + android:src="@drawable/appwidget_button_disabled" /> + - - - - - - - - - - - - - - + android:layout_height="wrap_content" + android:layout_width="fill_parent" + android:orientation="horizontal" > + + + + + + + + + + + + \ No newline at end of file diff --git a/MyTracks/res/layout/upload_result.xml b/MyTracks/res/layout/upload_result.xml index 65f20a9a5..8a95f2916 100644 --- a/MyTracks/res/layout/upload_result.xml +++ b/MyTracks/res/layout/upload_result.xml @@ -15,13 +15,12 @@ See the License for the specific language governing permissions and limitations under the License. --> + style="@style/ScrollView" > + android:orientation="vertical" + android:padding="8dp" > + style="@style/TextMedium" /> + style="@style/TextSmall" /> @@ -66,20 +62,17 @@ limitations under the License. android:layout_width="wrap_content" android:src="@drawable/success" /> + style="@style/TextMedium" /> + style="@style/TextSmall" /> @@ -96,36 +89,29 @@ limitations under the License. android:layout_width="wrap_content" android:src="@drawable/success" /> + style="@style/TextMedium" /> + style="@style/TextSmall" /> + style="@style/TextSmall" /> + style="@style/TextMedium" /> \ No newline at end of file diff --git a/MyTracks/res/layout/upload_service_chooser.xml b/MyTracks/res/layout/upload_service_chooser.xml index c4cc68a35..caabaf7bf 100644 --- a/MyTracks/res/layout/upload_service_chooser.xml +++ b/MyTracks/res/layout/upload_service_chooser.xml @@ -15,27 +15,21 @@ See the License for the specific language governing permissions and limitations under the License. --> + style="@style/ScrollView" > + android:src="@drawable/maps_icon" + style="@style/UploadServiceChooserImageView" /> + style="@style/UploadServiceChooserCheckBox" /> + style="@style/TextMedium" /> + style="@style/TextMedium" /> + android:src="@drawable/googledocs_icon" + style="@style/UploadServiceChooserImageView" /> + style="@style/UploadServiceChooserCheckBox" /> + android:src="@drawable/googledocs_icon" + style="@style/UploadServiceChooserImageView" /> + style="@style/UploadServiceChooserCheckBox" /> \ No newline at end of file diff --git a/MyTracks/res/layout/welcome.xml b/MyTracks/res/layout/welcome.xml index 6c0cbd992..f780f0faf 100644 --- a/MyTracks/res/layout/welcome.xml +++ b/MyTracks/res/layout/welcome.xml @@ -15,7 +15,6 @@ See the License for the specific language governing permissions and limitations under the License. --> - + style="@style/ScrollView" > + \ No newline at end of file diff --git a/MyTracks/res/values/strings.xml b/MyTracks/res/values/strings.xml index f7b83e32e..ed77b8e7c 100644 --- a/MyTracks/res/values/strings.xml +++ b/MyTracks/res/values/strings.xml @@ -929,11 +929,6 @@ limitations under the License. 'Maps' list page informing the user that he doesn't have any maps."> You don\'t have any maps. - - Pick a map: - @@ -946,8 +941,8 @@ limitations under the License. - Your Google Maps + page asking the user to pick a map."> + Pick a Map + 48dp + - - - - - - - - - - - - - - - - - - - + + + + - @@ -131,37 +92,62 @@ limitations under the License. 8dp - - + + + + + + + + + + + + + + + + - - - - - \ No newline at end of file diff --git a/MyTracks/src/com/google/android/apps/mytracks/TrackDetailActivity.java b/MyTracks/src/com/google/android/apps/mytracks/TrackDetailActivity.java index c44e12fe2..1c6f8e2d8 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/TrackDetailActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/TrackDetailActivity.java @@ -144,7 +144,7 @@ public class TrackDetailActivity extends FragmentActivity { trackDataHub = ((MyTracksApplication) getApplication()).getTrackDataHub(); trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, null); - mapViewContainer = getLayoutInflater().inflate(R.layout.mytracks_layout, null); + mapViewContainer = getLayoutInflater().inflate(R.layout.map, null); tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(); tabManager = new TabManager(this, tabHost, R.id.realtabcontent); diff --git a/MyTracks/src/com/google/android/apps/mytracks/fragments/ChartFragment.java b/MyTracks/src/com/google/android/apps/mytracks/fragments/ChartFragment.java index e0e8bf9a8..5e667ee83 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/fragments/ChartFragment.java +++ b/MyTracks/src/com/google/android/apps/mytracks/fragments/ChartFragment.java @@ -42,7 +42,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; -import android.widget.LinearLayout; import android.widget.ZoomControls; import java.util.ArrayList; @@ -77,7 +76,6 @@ public class ChartFragment extends Fragment implements TrackDataListener { // UI elements private ChartView chartView; - private LinearLayout busyPane; private ZoomControls zoomControls; /** @@ -91,7 +89,6 @@ public class ChartFragment extends Fragment implements TrackDataListener { return; } - busyPane.setVisibility(View.GONE); zoomControls.setIsZoomInEnabled(chartView.canZoomIn()); zoomControls.setIsZoomOutEnabled(chartView.canZoomOut()); chartView.setShowPointer(isRecording()); @@ -113,9 +110,8 @@ public class ChartFragment extends Fragment implements TrackDataListener { @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.mytracks_charts, container, false); - busyPane = (LinearLayout) view.findViewById(R.id.elevation_busypane); - zoomControls = (ZoomControls) view.findViewById(R.id.elevation_zoom); + View view = inflater.inflate(R.layout.chart, container, false); + zoomControls = (ZoomControls) view.findViewById(R.id.chart_zoom_controls); zoomControls.setOnZoomInClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -134,7 +130,7 @@ public class ChartFragment extends Fragment implements TrackDataListener { @Override public void onStart() { super.onStart(); - ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.elevation_chart); + ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.chart_view_layout); LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); layout.addView(chartView, layoutParams); @@ -156,7 +152,7 @@ public class ChartFragment extends Fragment implements TrackDataListener { @Override public void onStop() { super.onStop(); - ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.elevation_chart); + ViewGroup layout = (ViewGroup) getActivity().findViewById(R.id.chart_view_layout); layout.removeView(chartView); } @@ -229,12 +225,7 @@ public class ChartFragment extends Fragment implements TrackDataListener { @Override public void onSelectedTrackChanged(Track track, boolean isRecording) { - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - busyPane.setVisibility(View.VISIBLE); - } - }); + // We don't care. } @Override diff --git a/MyTracks/src/com/google/android/apps/mytracks/fragments/MapFragment.java b/MyTracks/src/com/google/android/apps/mytracks/fragments/MapFragment.java index f1e6d1b01..b7aa282ec 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/fragments/MapFragment.java +++ b/MyTracks/src/com/google/android/apps/mytracks/fragments/MapFragment.java @@ -43,8 +43,6 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; @@ -85,11 +83,8 @@ public class MapFragment extends Fragment // UI elements private View mapViewContainer; private MapOverlay mapOverlay; - private RelativeLayout screen; private MapView mapView; - private LinearLayout messagePane; - private TextView messageText; - private LinearLayout busyPane; + private TextView messageTextView; @Override public View onCreateView( @@ -98,15 +93,12 @@ public class MapFragment extends Fragment mapOverlay = new MapOverlay(getActivity()); - screen = (RelativeLayout) mapViewContainer.findViewById(R.id.screen); - mapView = (MapView) mapViewContainer.findViewById(R.id.map); + mapView = (MapView) mapViewContainer.findViewById(R.id.map_view); mapView.requestFocus(); mapView.setOnTouchListener(this); mapView.setBuiltInZoomControls(true); mapView.getOverlays().add(mapOverlay); - messagePane = (LinearLayout) mapViewContainer.findViewById(R.id.messagepane); - messageText = (TextView) mapViewContainer.findViewById(R.id.messagetext); - busyPane = (LinearLayout) mapViewContainer.findViewById(R.id.busypane); + messageTextView = (TextView) mapViewContainer.findViewById(R.id.map_message); return mapViewContainer; } @@ -238,7 +230,7 @@ public class MapFragment extends Fragment @Override public void onClick(View v) { - if (v == messagePane) { + if (v == messageTextView) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); } @@ -270,21 +262,20 @@ public class MapFragment extends Fragment @Override public void run() { if (messageId != -1) { - messageText.setText(messageId); - messagePane.setVisibility(View.VISIBLE); + messageTextView.setText(messageId); + messageTextView.setVisibility(View.VISIBLE); if (isGpsDisabled) { Toast.makeText(getActivity(), R.string.gps_not_found, Toast.LENGTH_LONG).show(); // Click to show the location source settings - messagePane.setOnClickListener(MapFragment.this); + messageTextView.setOnClickListener(MapFragment.this); } else { - messagePane.setOnClickListener(null); + messageTextView.setOnClickListener(null); } } else { - messagePane.setVisibility(View.GONE); + messageTextView.setVisibility(View.GONE); } - screen.requestLayout(); } }); } @@ -310,9 +301,7 @@ public class MapFragment extends Fragment boolean hasTrack = track != null; mapOverlay.setTrackDrawingEnabled(hasTrack); - if (hasTrack) { - busyPane.setVisibility(View.VISIBLE); - + if (hasTrack) { synchronized (this) { /* * Synchronize to prevent race condition in changing markerTrackId @@ -322,7 +311,6 @@ public class MapFragment extends Fragment updateMap(track); } mapOverlay.setShowEndMarker(!isRecording); - busyPane.setVisibility(View.GONE); } mapView.invalidate(); } diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/maps/ChooseMapActivity.java b/MyTracks/src/com/google/android/apps/mytracks/io/maps/ChooseMapActivity.java index 9b5d5a23b..815830e81 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/maps/ChooseMapActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/maps/ChooseMapActivity.java @@ -68,11 +68,11 @@ public class ChooseMapActivity extends Activity { } MapsMapMetadata mapData = getItem(position).getMapData(); - TextView title = (TextView) convertView.findViewById(R.id.choose_map_list_item_title); + TextView title = (TextView) convertView.findViewById(R.id.choose_map_item_title); title.setText(mapData.getTitle()); TextView description = (TextView) convertView.findViewById( - R.id.choose_map_list_item_description); + R.id.choose_map_item_description); String descriptionText = mapData.getDescription(); if (descriptionText == null || descriptionText.equals("")) { description.setVisibility(View.GONE); @@ -82,7 +82,7 @@ public class ChooseMapActivity extends Activity { } TextView searchStatus = (TextView) convertView.findViewById( - R.id.choose_map_list_item_search_status); + R.id.choose_map_item_search_status); searchStatus.setTextColor(mapData.getSearchable() ? Color.RED : Color.GREEN); searchStatus.setText(mapData.getSearchable() ? R.string.maps_list_public_label : R.string.maps_list_unlisted_label);