5 new revisions:
Revision: 87fb159a1680
Branch: default
Author: Jimmy Shih <
js...@google.com>
Date: Fri Oct 5 11:26:57 2012
Log: Add a widget configuration screen
http://code.google.com/p/mytracks/source/detail?r=87fb159a1680
Revision: 970475bced2c
Branch: default
Author: Jimmy Shih <
js...@google.com>
Date: Mon Oct 8 13:05:15 2012
Log: add 4 layout sizes for the app widget
http://code.google.com/p/mytracks/source/detail?r=970475bced2c
Revision: ad1cde9dc398
Branch: default
Author: Jimmy Shih <
js...@google.com>
Date: Mon Oct 8 15:22:39 2012
Log: update app widget style
http://code.google.com/p/mytracks/source/detail?r=ad1cde9dc398
Revision: 481b7b2ee0b0
Branch: default
Author: Jimmy Shih <
js...@google.com>
Date: Mon Oct 8 17:25:27 2012
Log: add chronometer to each app widget item
http://code.google.com/p/mytracks/source/detail?r=481b7b2ee0b0
Revision: a2a777b9be31
Branch: default
Author: Jimmy Shih <
js...@google.com>
Date: Mon Oct 8 18:36:28 2012
Log: fix layout issue in track widget config activity
http://code.google.com/p/mytracks/source/detail?r=a2a777b9be31
==============================================================================
Revision: 87fb159a1680
Branch: default
Author: Jimmy Shih <
js...@google.com>
Date: Fri Oct 5 11:26:57 2012
Log: Add a widget configuration screen
http://code.google.com/p/mytracks/source/detail?r=87fb159a1680
Added:
/MyTracks/res/layout-v14/bottom_buttons.xml
/MyTracks/res/layout/bottom_buttons.xml
/MyTracks/res/layout/track_widget_config.xml
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetConfigActivity.java
Modified:
/MyTracks/AndroidManifest.xml
/MyTracks/res/layout/track_controller.xml
/MyTracks/res/layout/track_widget_large.xml
/MyTracks/res/layout/track_widget_small.xml
/MyTracks/res/values/keys.xml
/MyTracks/res/values/strings.xml
/MyTracks/res/values/styles.xml
/MyTracks/res/xml/track_widget_info.xml
/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
=======================================
--- /dev/null
+++ /MyTracks/res/layout-v14/bottom_buttons.xml Fri Oct 5 11:26:57 2012
@@ -0,0 +1,28 @@
+<?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/bottom_buttons_cancel"
+ android:layout_gravity="left"
+ android:text="@string/generic_cancel"
+ style="@style/BottomButton" />
+ <Button
+ android:id="@+id/bottom_buttons_add"
+ android:layout_gravity="right"
+ android:text="@string/generic_add"
+ style="@style/BottomButton" />
+</merge>
=======================================
--- /dev/null
+++ /MyTracks/res/layout/bottom_buttons.xml Fri Oct 5 11:26:57 2012
@@ -0,0 +1,28 @@
+<?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/bottom_buttons_add"
+ android:layout_gravity="left"
+ android:text="@string/generic_add"
+ style="@style/BottomButton" />
+ <Button
+ android:id="@+id/bottom_buttons_cancel"
+ android:layout_gravity="right"
+ android:text="@string/generic_cancel"
+ style="@style/BottomButton" />
+</merge>
=======================================
--- /dev/null
+++ /MyTracks/res/layout/track_widget_config.xml Fri Oct 5 11:26:57 2012
@@ -0,0 +1,49 @@
+<?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.
+-->
+<LinearLayout xmlns:android="
http://schemas.android.com/apk/res/android"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent"
+ android:orientation="vertical" >
+ <ScrollView style="@style/ScrollView.WithBottomButtons" >
+ <TableLayout
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:padding="8dp" >
+ <TableRow style="@style/TrackWidgetConfigRow" >
+ <Spinner
+ android:id="@+id/track_widget_config_item1"
+ style="@style/TrackWidgetConfigSpinner" />
+ <LinearLayout style="@style/TrackWidgetConfigSpacer" />
+ <Spinner
+ android:id="@+id/track_widget_config_item3"
+ style="@style/TrackWidgetConfigSpinner" />
+ </TableRow>
+ <TableRow style="@style/TrackWidgetConfigRow" >
+ <Spinner
+ android:id="@+id/track_widget_config_item2"
+ style="@style/TrackWidgetConfigSpinner" />
+ <LinearLayout style="@style/TrackWidgetConfigSpacer" />
+ <Spinner
+ android:id="@+id/track_widget_config_item4"
+ style="@style/TrackWidgetConfigSpinner" />
+ </TableRow>
+ </TableLayout>
+ </ScrollView>
+ <LinearLayout style="@style/BottomButtonBar" >
+ <include layout="@layout/bottom_buttons" />
+ </LinearLayout>
+</LinearLayout>
=======================================
--- /dev/null
+++
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetConfigActivity.java
Fri Oct 5 11:26:57 2012
@@ -0,0 +1,137 @@
+/*
+ * 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.
+ */
+
+package com.google.android.apps.mytracks.widgets;
+
+import com.google.android.apps.mytracks.util.PreferencesUtils;
+import com.google.android.maps.mytracks.R;
+
+import android.app.Activity;
+import android.appwidget.AppWidgetManager;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.Spinner;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Activity to configure the track widget.
+ *
+ * @author Jimmy Shih
+ */
+public class TrackWidgetConfigActivity extends Activity {
+
+ private int appWidgetId;
+ private Spinner item1;
+ private Spinner item2;
+ private Spinner item3;
+ private Spinner item4;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ /*
+ * Set the result to CANCELED. This will cause the widget host to
cancel out
+ * of the widget placement if they press the back button.
+ */
+ setResult(RESULT_CANCELED);
+
+ setContentView(R.layout.track_widget_config);
+ item1 = (Spinner) findViewById(R.id.track_widget_config_item1);
+ item2 = (Spinner) findViewById(R.id.track_widget_config_item2);
+ item3 = (Spinner) findViewById(R.id.track_widget_config_item3);
+ item4 = (Spinner) findViewById(R.id.track_widget_config_item4);
+
+ boolean reportSpeed = PreferencesUtils.getBoolean(
+ this, R.string.report_speed_key,
PreferencesUtils.REPORT_SPEED_DEFAULT);
+
+ List<CharSequence> list = new ArrayList<CharSequence>();
+ addItem(list, R.string.stats_total_distance);
+ addItem(list, R.string.stats_total_time);
+ addItem(list, reportSpeed ? R.string.stats_average_speed :
R.string.stats_average_pace);
+ addItem(list, R.string.stats_moving_time);
+ addItem(list,
+ reportSpeed ? R.string.stats_average_moving_speed :
R.string.stats_average_moving_pace);
+
+ configSpinner(item1, list, PreferencesUtils.getInt(
+ this, R.string.track_widget_item1,
PreferencesUtils.TRACK_WIDGET_ITEM1_DEFAULT));
+ configSpinner(item2, list, PreferencesUtils.getInt(
+ this, R.string.track_widget_item2,
PreferencesUtils.TRACK_WIDGET_ITEM2_DEFAULT));
+ configSpinner(item3, list, PreferencesUtils.getInt(
+ this, R.string.track_widget_item3,
PreferencesUtils.TRACK_WIDGET_ITEM3_DEFAULT));
+ configSpinner(item4, list, PreferencesUtils.getInt(
+ this, R.string.track_widget_item4,
PreferencesUtils.TRACK_WIDGET_ITEM4_DEFAULT));
+
+ findViewById(R.id.bottom_buttons_add).setOnClickListener(new
View.OnClickListener() {
+ public void onClick(View v) {
+
+ // Push widget update to surface with newly set prefix
+ AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(
+ TrackWidgetConfigActivity.this);
+ TrackWidgetProvider.updateAppWidget(
+ TrackWidgetConfigActivity.this, appWidgetManager, appWidgetId);
+ PreferencesUtils.setInt(TrackWidgetConfigActivity.this,
R.string.track_widget_item1,
+ item1.getSelectedItemPosition());
+ PreferencesUtils.setInt(TrackWidgetConfigActivity.this,
R.string.track_widget_item2,
+ item2.getSelectedItemPosition());
+ PreferencesUtils.setInt(TrackWidgetConfigActivity.this,
R.string.track_widget_item3,
+ item3.getSelectedItemPosition());
+ PreferencesUtils.setInt(TrackWidgetConfigActivity.this,
R.string.track_widget_item4,
+ item4.getSelectedItemPosition());
+
+ // Make sure we pass back the original appWidgetId
+ Intent resultValue = new Intent();
+ resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
appWidgetId);
+ setResult(RESULT_OK, resultValue);
+ finish();
+ }
+ });
+ findViewById(R.id.bottom_buttons_cancel).setOnClickListener(new
View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finish();
+ }
+ });
+
+ // Find the app widget id from the intent.
+ Intent intent = getIntent();
+ Bundle extras = intent.getExtras();
+ appWidgetId = extras != null ? extras.getInt(
+ AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID)
+ : AppWidgetManager.INVALID_APPWIDGET_ID;
+
+ // If they gave us an intent without the widget id, just bail.
+ if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
+ finish();
+ }
+ }
+
+ private void addItem(List<CharSequence> list, int id) {
+ list.add(getString(id).toUpperCase());
+ }
+
+ private void configSpinner(Spinner spinner, List<CharSequence> list, int
position) {
+ ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(
+ this, android.R.layout.simple_spinner_item, list);
+
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ spinner.setAdapter(adapter);
+ spinner.setSelection(position);
+ }
+}
=======================================
--- /MyTracks/AndroidManifest.xml Thu Sep 20 17:27:10 2012
+++ /MyTracks/AndroidManifest.xml Fri Oct 5 11:26:57 2012
@@ -19,7 +19,6 @@
android:versionCode="56"
android:versionName="2.0.2"
package="com.google.android.maps.mytracks" >
-
<!-- Permission to initialize services -->
<uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- Permissions to record locations -->
@@ -79,7 +78,6 @@
android:name="com.google.android.apps.mytracks.WRITE_TRACK_DATA"
android:permissionGroup="android.permission-group.LOCATION"
android:protectionLevel="dangerous" />
-
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="16" />
@@ -115,22 +113,19 @@
<uses-feature
android:name="android.hardware.touchscreen.multitouch"
android:required="false" />
-
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
-
<application
android:backupAgent="com.google.android.apps.mytracks.io.backup.MyTracksBackupAgent"
- android:icon="@drawable/my_tracks_icon"
android:hardwareAccelerated="true"
+ android:icon="@drawable/my_tracks_icon"
android:label="@string/my_tracks_app_name"
android:name="com.google.android.apps.mytracks.MyTracksApplication"
android:theme="@style/ThemeSelector" >
-
<!-- For data backup -->
<meta-data
android:name="com.google.android.backup.api_key"
@@ -142,15 +137,12 @@
<activity
android:label="@string/menu_help"
android:name="com.google.android.apps.mytracks.HelpActivity" />
- <activity
- android:name="com.google.android.apps.mytracks.ImportActivity" >
+ <activity
android:name="com.google.android.apps.mytracks.ImportActivity" >
<intent-filter>
<action android:name="android.intent.action.ATTACH_DATA" />
<action android:name="android.intent.action.VIEW" />
-
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
-
<data android:mimeType="application/gpx" />
<data android:mimeType="application/gpx+xml" />
<data android:mimeType="application/vnd.google-earth.gpx" />
@@ -158,8 +150,7 @@
<data android:scheme="file" />
</intent-filter>
</activity>
- <activity
- android:name="com.google.android.apps.mytracks.MarkerEditActivity" />
+ <activity
android:name="com.google.android.apps.mytracks.MarkerEditActivity" />
<activity
android:name="com.google.android.apps.mytracks.MarkerDetailActivity" />
<activity
android:name="com.google.android.apps.mytracks.MarkerListActivity" >
<meta-data
@@ -172,7 +163,6 @@
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
-
<meta-data
android:name="android.app.searchable"
android:resource="@xml/search" />
@@ -181,15 +171,12 @@
android:label="@string/menu_sensor_state"
android:name="com.google.android.apps.mytracks.SensorStateActivity"
/>
<activity
android:name="com.google.android.apps.mytracks.TrackDetailActivity" />
- <activity
- android:name="com.google.android.apps.mytracks.TrackEditActivity" />
+ <activity
android:name="com.google.android.apps.mytracks.TrackEditActivity" />
<activity
android:name="com.google.android.apps.mytracks.TrackListActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
-
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
-
<meta-data
android:name="android.app.default_searchable"
android:value="com.google.android.apps.mytracks.SearchListActivity" />
@@ -215,6 +202,13 @@
<activity
android:name="com.google.android.apps.mytracks.settings.SettingsActivity" />
<activity
android:name="com.google.android.apps.mytracks.settings.SharingSettingsActivity"
/>
<activity
android:name="com.google.android.apps.mytracks.settings.StatsSettingsActivity"
/>
+ <activity
+ android:label="@string/track_widget_config_title"
+
android:name="com.google.android.apps.mytracks.widgets.TrackWidgetConfigActivity"
>
+ <intent-filter>
+ <action
android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
+ </intent-filter>
+ </activity>
<!-- Services -->
<service
android:exported="false"
@@ -259,8 +253,6 @@
android:authorities="com.google.android.maps.mytracks.search"
android:exported="false"
android:name="com.google.android.apps.mytracks.content.SearchEngineProvider"
/>
-
<uses-library android:name="com.google.android.maps" />
</application>
-
</manifest>
=======================================
--- /MyTracks/res/layout/track_controller.xml Wed Sep 5 13:05:12 2012
+++ /MyTracks/res/layout/track_controller.xml Fri Oct 5 11:26:57 2012
@@ -52,7 +52,7 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:singleLine="true"
- style="@style/TextTiny" />
+ style="@style/TextMicro" />
</RelativeLayout>
<ImageButton
android:background="@android:color/transparent"
=======================================
--- /MyTracks/res/layout/track_widget_large.xml Tue Oct 2 14:30:53 2012
+++ /MyTracks/res/layout/track_widget_large.xml Fri Oct 5 11:26:57 2012
@@ -20,106 +20,117 @@
android:layout_width="fill_parent"
android:padding="@dimen/widget_margin" >
<LinearLayout
- android:clickable="true"
- android:id="@+id/track_widget_statistics"
android:layout_alignParentTop="true"
- android:layout_height="wrap_content"
+ android:layout_height="fill_parent"
android:layout_width="fill_parent"
- android:orientation="vertical"
- android:padding="4dp" >
- <LinearLayout style="@style/LinearLayoutHorizontal" >
- <!-- average moving speed -->
- <LinearLayout style="@style/TrackWidgetItemContainer" >
- <TextView
- android:id="@+id/track_widget_average_moving_speed_label"
- style="@style/TrackWidgetLabel" />
- <LinearLayout style="@style/TrackWidgetValueContainer" >
+ android:orientation="vertical" >
+ <LinearLayout
+ android:clickable="true"
+ android:gravity="center_vertical"
+ android:id="@+id/track_widget_statistics"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:layout_width="fill_parent"
+ android:orientation="vertical"
+ android:padding="4dp" >
+ <LinearLayout style="@style/LinearLayoutHorizontal" >
+ <!-- item1 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer" >
<TextView
- android:id="@+id/track_widget_average_moving_speed_value"
- style="@style/TrackWidgetValue" />
+ android:id="@+id/track_widget_item1_label"
+ style="@style/TrackWidgetLabel" />
+ <LinearLayout style="@style/TrackWidgetValueContainer" >
+ <TextView
+ android:id="@+id/track_widget_item1_value"
+ style="@style/TrackWidgetValue" />
+ <TextView
+ android:id="@+id/track_widget_item1_unit"
+ style="@style/TrackWidgetUnit" />
+ </LinearLayout>
+ </LinearLayout>
+ <!-- vertical separator -->
+ <LinearLayout style="@style/LinearLayoutVertifcal" >
+ <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
+ <LinearLayout style="@style/TrackWidgetVerticalSeparator" />
+ </LinearLayout>
+ <!-- item3 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer" >
<TextView
- android:id="@+id/track_widget_average_moving_speed_unit"
- style="@style/TrackWidgetUnit" />
+ android:id="@+id/track_widget_item3_label"
+ style="@style/TrackWidgetLabel" />
+ <LinearLayout style="@style/TrackWidgetValueContainer" >
+ <TextView
+ android:id="@+id/track_widget_item3_value"
+ style="@style/TrackWidgetValue" />
+ <TextView
+ android:id="@+id/track_widget_item3_unit"
+ style="@style/TrackWidgetUnit" />
+ </LinearLayout>
</LinearLayout>
</LinearLayout>
- <!-- vertical separator -->
- <LinearLayout style="@style/LinearLayoutVertifcal" >
- <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
- <LinearLayout style="@style/TrackWidgetVerticalSeparator" />
- </LinearLayout>
- <!-- moving time -->
- <LinearLayout style="@style/TrackWidgetItemContainer" >
- <TextView
- android:text="@string/stats_moving_time"
- style="@style/TrackWidgetLabel" />
- <LinearLayout style="@style/TrackWidgetValueContainer" >
+ <!-- horizontal separator -->
+ <LinearLayout style="@style/TrackWidgetHorizontalSeparator" />
+ <LinearLayout style="@style/LinearLayoutHorizontal" >
+ <!-- item2 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer" >
<TextView
- android:id="@+id/track_widget_moving_time_value"
- style="@style/TrackWidgetValue" />
+ android:id="@+id/track_widget_item2_label"
+ style="@style/TrackWidgetLabel" />
+ <LinearLayout style="@style/TrackWidgetValueContainer" >
+ <TextView
+ android:id="@+id/track_widget_item2_value"
+ style="@style/TrackWidgetValue" />
+ <TextView
+ android:id="@+id/track_widget_item2_unit"
+ style="@style/TrackWidgetUnit" />
+ </LinearLayout>
</LinearLayout>
- </LinearLayout>
- </LinearLayout>
- <!-- horizontal separator -->
- <LinearLayout style="@style/TrackWidgetHorizontalSeparator" />
- <LinearLayout style="@style/LinearLayoutHorizontal" >
- <!-- average speed -->
- <LinearLayout style="@style/TrackWidgetItemContainer" >
- <TextView
- android:id="@+id/track_widget_average_speed_label"
- style="@style/TrackWidgetLabel" />
- <LinearLayout style="@style/TrackWidgetValueContainer" >
- <TextView
- android:id="@+id/track_widget_average_speed_value"
- style="@style/TrackWidgetValue" />
- <TextView
- android:id="@+id/track_widget_average_speed_unit"
- style="@style/TrackWidgetUnit" />
+ <!-- vertical separator -->
+ <LinearLayout style="@style/LinearLayoutVertifcal" >
+ <LinearLayout style="@style/TrackWidgetVerticalSeparator" />
+ <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
</LinearLayout>
- </LinearLayout>
- <!-- vertical separator -->
- <LinearLayout style="@style/LinearLayoutVertifcal" >
- <LinearLayout style="@style/TrackWidgetVerticalSeparator" />
- <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
- </LinearLayout>
- <!-- total distance -->
- <LinearLayout style="@style/TrackWidgetItemContainer" >
- <TextView
- android:text="@string/stats_total_distance"
- style="@style/TrackWidgetLabel" />
- <LinearLayout style="@style/TrackWidgetValueContainer" >
- <TextView
- android:id="@+id/track_widget_total_distance_value"
- style="@style/TrackWidgetValue" />
+ <!-- item4 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer" >
<TextView
- android:id="@+id/track_widget_total_distance_unit"
- style="@style/TrackWidgetUnit" />
+ android:id="@+id/track_widget_item4_label"
+ style="@style/TrackWidgetLabel" />
+ <LinearLayout style="@style/TrackWidgetValueContainer" >
+ <TextView
+ android:id="@+id/track_widget_item4_value"
+ style="@style/TrackWidgetValue" />
+ <TextView
+ android:id="@+id/track_widget_item4_unit"
+ style="@style/TrackWidgetUnit" />
+ </LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
- </LinearLayout>
- <LinearLayout
- android:layout_below="@id/track_widget_statistics"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:orientation="horizontal"
- android:paddingBottom="4dp"
- android:paddingTop="4dp" >
- <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
- <ImageButton
- android:id="@+id/track_widget_record_button"
- style="@style/TrackWidgetRecordButton" />
- <TextView
- android:id="@+id/track_widget_record_status"
- android:layout_gravity="center_vertical"
- android:layout_height="wrap_content"
- android:layout_weight="4"
- android:layout_width="0dp"
- android:singleLine="true"
- style="@style/TextSmall" />
- <ImageButton
- android:id="@+id/track_widget_stop_button"
- style="@style/TrackWidgetStopButton" />
- <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
+ <LinearLayout
+ android:gravity="center_vertical"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:layout_width="fill_parent"
+ android:orientation="horizontal"
+ android:paddingBottom="4dp"
+ android:paddingTop="4dp" >
+ <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
+ <ImageButton
+ android:id="@+id/track_widget_record_button"
+ style="@style/TrackWidgetRecordButton" />
+ <TextView
+ android:id="@+id/track_widget_record_status"
+ android:layout_gravity="center_vertical"
+ android:layout_height="wrap_content"
+ android:layout_weight="4"
+ android:layout_width="0dp"
+ android:singleLine="true"
+ style="@style/TextSmall" />
+ <ImageButton
+ android:id="@+id/track_widget_stop_button"
+ style="@style/TrackWidgetStopButton" />
+ <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
+ </LinearLayout>
</LinearLayout>
<ImageView style="@style/TrackWidgetLogo" />
</RelativeLayout>
=======================================
--- /MyTracks/res/layout/track_widget_small.xml Tue Oct 2 14:30:53 2012
+++ /MyTracks/res/layout/track_widget_small.xml Fri Oct 5 11:26:57 2012
@@ -45,13 +45,17 @@
android:layout_weight="1"
android:layout_width="fill_parent"
android:orientation="vertical" >
+ <!-- item1 -->
<TextView
- android:text="@string/stats_moving_time"
+ android:id="@+id/track_widget_item1_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer" >
<TextView
- android:id="@+id/track_widget_moving_time_value"
+ android:id="@+id/track_widget_item1_value"
style="@style/TrackWidgetValue" />
+ <TextView
+ android:id="@+id/track_widget_item1_unit"
+ style="@style/TrackWidgetUnit" />
</LinearLayout>
</LinearLayout>
<LinearLayout style="@style/TrackWidgetHorizontalSeparator" />
@@ -60,15 +64,16 @@
android:layout_weight="1"
android:layout_width="fill_parent"
android:orientation="vertical" >
+ <!-- item2 -->
<TextView
- android:text="@string/stats_total_distance"
+ android:id="@+id/track_widget_item2_label"
style="@style/TrackWidgetLabel" />
<LinearLayout style="@style/TrackWidgetValueContainer" >
<TextView
- android:id="@+id/track_widget_total_distance_value"
+ android:id="@+id/track_widget_item2_value"
style="@style/TrackWidgetValue" />
<TextView
- android:id="@+id/track_widget_total_distance_unit"
+ android:id="@+id/track_widget_item2_unit"
style="@style/TrackWidgetUnit" />
</LinearLayout>
</LinearLayout>
=======================================
--- /MyTracks/res/values/keys.xml Mon Sep 17 15:00:14 2012
+++ /MyTracks/res/values/keys.xml Fri Oct 5 11:26:57 2012
@@ -54,8 +54,12 @@
<string name="track_color_mode_slow_key">trackColorModeSlow</string>
<string name="track_color_mode_key">trackColorMode</string>
<string name="track_name_key">trackName</string>
+ <string name="track_widget_item1">trackWidgetItem1</string>
+ <string name="track_widget_item2">trackWidgetItem2</string>
+ <string name="track_widget_item3">trackWidgetItem3</string>
+ <string name="track_widget_item4">trackWidgetItem4</string>
<string name="voice_frequency_key">voiceFrequency</string>
-
+
<!-- Keys for persistend preferences. But they should not get backed up
or restored. -->
<string
name="auto_resume_track_current_retry_key">autoResumeTrackCurrentRetry</string>
<string name="recording_track_id_key">recordingTrackId</string>
=======================================
--- /MyTracks/res/values/strings.xml Tue Oct 2 14:30:53 2012
+++ /MyTracks/res/values/strings.xml Fri Oct 5 11:26:57 2012
@@ -2293,6 +2293,12 @@
Recording your track…
</string>
+ <!-- Track Widget -->
+ <string name="track_widget_config_title"
+ translation_description="Title of the page to configure the My Tracks
widget items.">
+ Configure Widget Items
+ </string>
+
<!-- Unit -->
<string name="unit_feet"
translation_description="Abbreviation for feet. E.g., '2 ft'.">
=======================================
--- /MyTracks/res/values/styles.xml Tue Oct 2 14:30:53 2012
+++ /MyTracks/res/values/styles.xml Fri Oct 5 11:26:57 2012
@@ -192,11 +192,11 @@
<item name="android:layout_width">wrap_content</item>
<item name="android:textSize">14sp</item>
</style>
- <!-- The style for tiny size text -->
- <style name="TextTiny">
+ <!-- The style for micro size text -->
+ <style name="TextMicro">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
- <item name="android:textSize">10sp</item>
+ <item name="android:textSize">12sp</item>
</style>
<!-- Theme selector -->
<style name="ThemeSelector" parent="android:Theme" />
@@ -212,6 +212,26 @@
<item name="android:layout_gravity">center_vertical</item>
<item name="android:scaleType">fitXY</item>
</style>
+ <!-- The style for the track widget config row -->
+ <style name="TrackWidgetConfigRow">
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:paddingTop">16dp</item>
+ <item name="android:paddingBottom">16dp</item>
+ </style>
+ <!-- The style for the track widget config spacer -->
+ <style name="TrackWidgetConfigSpacer">
+ <item name="android:layout_height">fill_parent</item>
+ <item name="android:layout_weight">2</item>
+ <item name="android:layout_width">0dp</item>
+ </style>
+ <!-- The style for the track widget config spiner -->
+ <style name="TrackWidgetConfigSpinner">
+ <item name="android:gravity">left</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_weight">9</item>
+ <item name="android:layout_width">0dp</item>
+ </style>
<!-- The style for the track widget horizontal separator -->
<style name="TrackWidgetHorizontalSeparator">
<item name="android:background">@color/track_widget_line</item>
@@ -229,20 +249,22 @@
<item name="android:paddingTop">2dp</item>
</style>
<!-- The style for the track widget label -->
- <style name="TrackWidgetLabel" parent="@style/TextSmall">
+ <style name="TrackWidgetLabel">
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:singleLine">true</item>
<item name="android:textAllCaps">true</item>
<item name="android:textColor">@color/orange</item>
+ <item name="android:textSize">10dp</item>
+ <item name="android:textStyle">bold</item>
</style>
<style name="TrackWidgetLogo">
<item
name="android:contentDescription">@string/my_tracks_app_name</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_alignParentTop">true</item>
<item name="android:layout_height">24dp</item>
- <item name="android:layout_width">20dp</item>
+ <item name="android:layout_width">24dp</item>
<item name="android:padding">4dp</item>
<item name="android:scaleType">fitXY</item>
<item name="android:src">@drawable/my_tracks_icon</item>
@@ -262,15 +284,16 @@
<item name="android:src">@drawable/btn_stop_0</item>
</style>
<!-- The style for the track widget unit -->
- <style name="TrackWidgetUnit" parent="@style/TextSmall">
+ <style name="TrackWidgetUnit">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_width">0dp</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:singleLine">true</item>
+ <item name="android:textSize">10dp</item>
</style>
<!-- The style for the track widget value -->
- <style name="TrackWidgetValue" parent="@style/TextSmall">
+ <style name="TrackWidgetValue" parent="@style/TextMedium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">2</item>
<item name="android:layout_width">0dp</item>
@@ -282,6 +305,7 @@
<style name="TrackWidgetValueContainer">
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_marginTop">-4dp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:orientation">horizontal</item>
</style>
=======================================
--- /MyTracks/res/xml/track_widget_info.xml Tue Oct 2 14:30:53 2012
+++ /MyTracks/res/xml/track_widget_info.xml Fri Oct 5 11:26:57 2012
@@ -15,6 +15,7 @@
limitations under the License.
-->
<appwidget-provider
xmlns:android="
http://schemas.android.com/apk/res/android"
+
android:configure="com.google.android.apps.mytracks.widgets.TrackWidgetConfigActivity"
android:initialLayout="@layout/track_widget_large"
android:minHeight="110dp"
android:minResizeHeight="40dp"
=======================================
---
/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java
Tue Sep 25 13:06:40 2012
+++
/MyTracks/src/com/google/android/apps/mytracks/util/PreferencesUtils.java
Fri Oct 5 11:26:57 2012
@@ -91,6 +91,11 @@
public static final String TRACK_NAME_DEFAULT = "LOCATION";
+ public static final int TRACK_WIDGET_ITEM1_DEFAULT = 3; // moving time
+ public static final int TRACK_WIDGET_ITEM2_DEFAULT = 0; // distance
+ public static final int TRACK_WIDGET_ITEM3_DEFAULT = 1; // total time
+ public static final int TRACK_WIDGET_ITEM4_DEFAULT = 2; // average speed
+
public static final int VOICE_FREQUENCY_DEFAULT = 0;
private PreferencesUtils() {}
=======================================
---
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
Tue Oct 2 14:30:53 2012
+++
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
Fri Oct 5 11:26:57 2012
@@ -37,6 +37,7 @@
import android.os.Bundle;
import android.support.v4.app.TaskStackBuilder;
import android.util.SparseBooleanArray;
+import android.view.View;
import android.widget.RemoteViews;
/**
@@ -57,8 +58,7 @@
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
String action = intent.getAction();
- if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)
- ||
context.getString(R.string.track_paused_broadcast_action).equals(action)
+ if
(context.getString(R.string.track_paused_broadcast_action).equals(action)
||
context.getString(R.string.track_resumed_broadcast_action).equals(action)
||
context.getString(R.string.track_started_broadcast_action).equals(action)
||
context.getString(R.string.track_stopped_broadcast_action).equals(action)
@@ -69,7 +69,8 @@
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
new ComponentName(context, TrackWidgetProvider.class));
for (int appWidgetId : appWidgetIds) {
- RemoteViews remoteViews = getRemoteViews(context, trackId,
useLargeSize.get(appWidgetId));
+ RemoteViews remoteViews = getRemoteViews(
+ context, trackId, useLargeSize.get(appWidgetId, true));
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
}
@@ -87,13 +88,26 @@
}
/**
- * Updates the widget.
+ * Updates an app widget.
+ *
+ * @param context the context
+ * @param appWidgetManager the app widget manager
+ * @param appWidgetId the app widget id
+ */
+ public static void updateAppWidget(
+ Context context, AppWidgetManager appWidgetManager, int appWidgetId)
{
+ RemoteViews remoteViews = getRemoteViews(context, -1L,
useLargeSize.get(appWidgetId, true));
+ appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
+ }
+
+ /**
+ * Gets the remote views.
*
* @param context the context
* @param trackId the track id
* @param large true to use the large layout
*/
- private RemoteViews getRemoteViews(Context context, long trackId,
boolean large) {
+ private static RemoteViews getRemoteViews(Context context, long trackId,
boolean large) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
large ? R.layout.track_widget_large : R.layout.track_widget_small);
@@ -104,6 +118,12 @@
R.string.recording_track_paused_key,
PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
boolean metricUnits = PreferencesUtils.getBoolean(
context, R.string.metric_units_key,
PreferencesUtils.METRIC_UNITS_DEFAULT);
+ boolean reportSpeed = PreferencesUtils.getBoolean(
+ context, R.string.report_speed_key,
PreferencesUtils.REPORT_SPEED_DEFAULT);
+ int item1 = PreferencesUtils.getInt(
+ context, R.string.track_widget_item1,
PreferencesUtils.TRACK_WIDGET_ITEM1_DEFAULT);
+ int item2 = PreferencesUtils.getInt(
+ context, R.string.track_widget_item2,
PreferencesUtils.TRACK_WIDGET_ITEM2_DEFAULT);
// Get track and trip statistics
MyTracksProviderUtils myTracksProviderUtils =
MyTracksProviderUtils.Factory.get(context);
@@ -115,19 +135,65 @@
TripStatistics tripStatistics = track == null ? null :
track.getTripStatistics();
updateStatisticsContainer(context, remoteViews, track);
- updateMovingTime(context, remoteViews, tripStatistics);
- updateTotalDistance(context, remoteViews, tripStatistics, metricUnits);
+ setItem(context, remoteViews, R.id.track_widget_item1_label,
R.id.track_widget_item1_value,
+ R.id.track_widget_item1_unit, item1, tripStatistics, metricUnits,
reportSpeed);
+ setItem(context, remoteViews, R.id.track_widget_item2_label,
R.id.track_widget_item2_value,
+ R.id.track_widget_item2_unit, item2, tripStatistics, metricUnits,
reportSpeed);
+
updateRecordButton(context, remoteViews, isRecording,
recordingTrackPaused);
updateStopButton(context, remoteViews, isRecording);
if (large) {
- boolean reportSpeed = PreferencesUtils.getBoolean(
- context, R.string.report_speed_key,
PreferencesUtils.REPORT_SPEED_DEFAULT);
- updateAverageMovingSpeed(context, remoteViews, tripStatistics,
metricUnits, reportSpeed);
- updateAverageSpeed(context, remoteViews, tripStatistics,
metricUnits, reportSpeed);
+ int item3 = PreferencesUtils.getInt(
+ context, R.string.track_widget_item3,
PreferencesUtils.TRACK_WIDGET_ITEM3_DEFAULT);
+ int item4 = PreferencesUtils.getInt(
+ context, R.string.track_widget_item4,
PreferencesUtils.TRACK_WIDGET_ITEM4_DEFAULT);
+ setItem(context, remoteViews, R.id.track_widget_item3_label,
R.id.track_widget_item3_value,
+ R.id.track_widget_item3_unit, item3, tripStatistics,
metricUnits, reportSpeed);
+ setItem(context, remoteViews, R.id.track_widget_item4_label,
R.id.track_widget_item4_value,
+ R.id.track_widget_item4_unit, item4, tripStatistics,
metricUnits, reportSpeed);
updateRecordStatus(context, remoteViews, isRecording,
recordingTrackPaused);
}
return remoteViews;
}
+
+ /**
+ * Sets a widget item.
+ *
+ * @param context the context
+ * @param remoteViews the remote view
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
+ * @param itemValue the item value
+ * @param tripStatistics the trip statistics
+ * @param metricUnits true to use metric units
+ * @param reportSpeed try to report speed
+ */
+ private static void setItem(Context context, RemoteViews remoteViews,
int labelId, int valueId,
+ int unitId, int itemValue, TripStatistics tripStatistics, boolean
metricUnits,
+ boolean reportSpeed) {
+ switch (itemValue) {
+ case 1:
+ updateTotalTime(context, remoteViews, labelId, valueId, unitId,
tripStatistics);
+ break;
+ case 2:
+ updateAverageSpeed(context, remoteViews, labelId, valueId, unitId,
tripStatistics,
+ metricUnits, reportSpeed);
+ break;
+ case 3:
+ updateMovingTime(context, remoteViews, labelId, valueId, unitId,
tripStatistics);
+ break;
+ case 4:
+ updateAverageMovingSpeed(context, remoteViews, labelId, valueId,
unitId, tripStatistics,
+ metricUnits, reportSpeed);
+ break;
+ case 0:
+ default:
+ updateTotalDistance(
+ context, remoteViews, labelId, valueId, unitId,
tripStatistics, metricUnits);
+ break;
+ }
+ }
/**
* Updates the statistics container.
@@ -136,7 +202,8 @@
* @param remoteViews the remote views
* @param track the track
*/
- private void updateStatisticsContainer(Context context, RemoteViews
remoteViews, Track track) {
+ private static void updateStatisticsContainer(
+ Context context, RemoteViews remoteViews, Track track) {
Intent intent;
if (track != null) {
intent = IntentUtils.newIntent(context, TrackDetailActivity.class)
@@ -149,35 +216,113 @@
PendingIntent pendingIntent = taskStackBuilder.getPendingIntent(0, 0);
remoteViews.setOnClickPendingIntent(R.id.track_widget_statistics,
pendingIntent);
}
+
+ /**
+ * Updates total distance.
+ *
+ * @param context the context
+ * @param remoteViews the remote views
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
+ * @param tripStatistics the trip statistics
+ * @param metricUnits true to use metric units
+ */
+ private static void updateTotalDistance(Context context, RemoteViews
remoteViews, int labelId,
+ int valueId, int unitId, TripStatistics tripStatistics, boolean
metricUnits) {
+ double totalDistance = tripStatistics == null ? Double.NaN :
tripStatistics.getTotalDistance();
+ String[] totalDistanceParts = StringUtils.getDistanceParts(context,
totalDistance, metricUnits);
+ remoteViews.setTextViewText(labelId,
context.getString(R.string.stats_total_distance));
+ remoteViews.setTextViewText(valueId, totalDistanceParts[0]);
+ remoteViews.setTextViewText(unitId, totalDistanceParts[1]);
+ }
+
+ /**
+ * Updates total time.
+ *
+ * @param context the context
+ * @param remoteViews the remote views
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
+ * @param tripStatistics the trip statistics
+ */
+ private static void updateTotalTime(Context context, RemoteViews
remoteViews, int labelId,
+ int valueId, int unitId, TripStatistics tripStatistics) {
+ String totalTime = tripStatistics == null ?
context.getString(R.string.value_unknown)
+ : StringUtils.formatElapsedTime(tripStatistics.getTotalTime());
+ remoteViews.setTextViewText(labelId,
context.getString(R.string.stats_total_time));
+ remoteViews.setTextViewText(valueId, totalTime);
+ remoteViews.setViewVisibility(unitId, View.GONE);
+ }
+
+ /**
+ * Updates average speed.
+ *
+ * @param context the context
+ * @param remoteViews the remote views
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
+ * @param tripStatistics the trip statistics
+ * @param metricUnits true to use metric units
+ * @param reportSpeed true to report speed
+ */
+ private static void updateAverageSpeed(Context context, RemoteViews
remoteViews, int labelId,
+ int valueId, int unitId, TripStatistics tripStatistics, boolean
metricUnits,
+ boolean reportSpeed) {
+ String averageSpeedLabel = context.getString(
+ reportSpeed ? R.string.stats_average_speed :
R.string.stats_average_pace);
+ remoteViews.setTextViewText(labelId, averageSpeedLabel);
+
+ Double speed = tripStatistics == null ? Double.NaN :
tripStatistics.getAverageSpeed();
+ String[] speedParts = StringUtils.getSpeedParts(context, speed,
metricUnits, reportSpeed);
+ remoteViews.setTextViewText(valueId, speedParts[0]);
+ remoteViews.setTextViewText(unitId, speedParts[1]);
+ }
/**
* Updates moving time.
*
* @param context the context
* @param remoteViews the remote views
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
* @param tripStatistics the trip statistics
*/
- private void updateMovingTime(
- Context context, RemoteViews remoteViews, TripStatistics
tripStatistics) {
- String movingTimeValue = tripStatistics == null ?
context.getString(R.string.value_unknown)
+ private static void updateMovingTime(Context context, RemoteViews
remoteViews, int labelId,
+ int valueId, int unitId, TripStatistics tripStatistics) {
+ String movingTime = tripStatistics == null ?
context.getString(R.string.value_unknown)
: StringUtils.formatElapsedTime(tripStatistics.getMovingTime());
- remoteViews.setTextViewText(R.id.track_widget_moving_time_value,
movingTimeValue);
+ remoteViews.setTextViewText(labelId,
context.getString(R.string.stats_moving_time));
+ remoteViews.setTextViewText(valueId, movingTime);
+ remoteViews.setViewVisibility(unitId, View.GONE);
}
/**
- * Updates total distance.
+ * Updates average moving speed.
*
* @param context the context
* @param remoteViews the remote views
+ * @param labelId the label id
+ * @param valueId the value id
+ * @param unitId the unit id
* @param tripStatistics the trip statistics
* @param metricUnits true to use metric units
+ * @param reportSpeed true to report speed
*/
- private void updateTotalDistance(Context context, RemoteViews
remoteViews,
- TripStatistics tripStatistics, boolean metricUnits) {
- double distance = tripStatistics == null ? Double.NaN :
tripStatistics.getTotalDistance();
- String[] distanceParts = StringUtils.getDistanceParts(context,
distance, metricUnits);
- remoteViews.setTextViewText(R.id.track_widget_total_distance_value,
distanceParts[0]);
- remoteViews.setTextViewText(R.id.track_widget_total_distance_unit,
distanceParts[1]);
+ private static void updateAverageMovingSpeed(Context context,
RemoteViews remoteViews,
+ int labelId, int valueId, int unitId, TripStatistics tripStatistics,
boolean metricUnits,
+ boolean reportSpeed) {
+ String averageMovingSpeedLabel = context.getString(
+ reportSpeed ? R.string.stats_average_moving_speed :
R.string.stats_average_moving_pace);
+ remoteViews.setTextViewText(labelId, averageMovingSpeedLabel);
+
+ Double speed = tripStatistics == null ? Double.NaN :
tripStatistics.getAverageMovingSpeed();
+ String[] speedParts = StringUtils.getSpeedParts(context, speed,
metricUnits, reportSpeed);
+ remoteViews.setTextViewText(valueId, speedParts[0]);
+ remoteViews.setTextViewText(unitId, speedParts[1]);
}
/**
@@ -188,7 +333,7 @@
* @param isRecording true if recording
* @param recordingTrackPaused true if recording track is paused
*/
- private void updateRecordButton(
+ private static void updateRecordButton(
Context context, RemoteViews remoteViews, boolean isRecording,
boolean recordingTrackPaused) {
remoteViews.setImageViewResource(R.id.track_widget_record_button,
isRecording && !recordingTrackPaused ? R.drawable.btn_pause :
R.drawable.btn_record);
@@ -213,7 +358,8 @@
* @param remoteViews the remote views
* @param isRecording true if recording
*/
- private void updateStopButton(Context context, RemoteViews remoteViews,
boolean isRecording) {
+ private static void updateStopButton(
+ Context context, RemoteViews remoteViews, boolean isRecording) {
remoteViews.setImageViewResource(
R.id.track_widget_stop_button, isRecording ?
R.drawable.btn_stop_1 : R.drawable.btn_stop_0);
remoteViews.setBoolean(R.id.track_widget_stop_button, "setEnabled",
isRecording);
@@ -225,49 +371,6 @@
remoteViews.setOnClickPendingIntent(R.id.track_widget_stop_button,
pendingIntent);
}
}
-
- /**
- * Updates average moving speed.
- *
- * @param context the context
- * @param remoteViews the remote views
- * @param tripStatistics the trip statistics
- * @param metricUnits true to use metric units
- * @param reportSpeed true to report speed
- */
- private void updateAverageMovingSpeed(Context context, RemoteViews
remoteViews,
- TripStatistics tripStatistics, boolean metricUnits, boolean
reportSpeed) {
- String averageMovingSpeedLabel = context.getString(
- reportSpeed ? R.string.stats_average_moving_speed :
R.string.stats_average_moving_pace);
- remoteViews.setTextViewText(
- R.id.track_widget_average_moving_speed_label,
averageMovingSpeedLabel);
-
- Double speed = tripStatistics == null ? Double.NaN :
tripStatistics.getAverageMovingSpeed();
- String[] speedParts = StringUtils.getSpeedParts(context, speed,
metricUnits, reportSpeed);
-
remoteViews.setTextViewText(R.id.track_widget_average_moving_speed_value,
speedParts[0]);
-
remoteViews.setTextViewText(R.id.track_widget_average_moving_speed_unit,
speedParts[1]);
- }
-
- /**
- * Updates average speed.
- *
- * @param context the context
- * @param remoteViews the remote views
- * @param tripStatistics the trip statistics
- * @param metricUnits true to use metric units
- * @param reportSpeed true to report speed
- */
- private void updateAverageSpeed(Context context, RemoteViews remoteViews,
- TripStatistics tripStatistics, boolean metricUnits, boolean
reportSpeed) {
- String averageSpeedLabel = context.getString(
- reportSpeed ? R.string.stats_average_speed :
R.string.stats_average_pace);
- remoteViews.setTextViewText(R.id.track_widget_average_speed_label,
averageSpeedLabel);
-
- Double speed = tripStatistics == null ? Double.NaN :
tripStatistics.getAverageSpeed();
- String[] speedParts = StringUtils.getSpeedParts(context, speed,
metricUnits, reportSpeed);
- remoteViews.setTextViewText(R.id.track_widget_average_speed_value,
speedParts[0]);
- remoteViews.setTextViewText(R.id.track_widget_average_speed_unit,
speedParts[1]);
- }
/**
* Updates recording status.
@@ -277,7 +380,7 @@
* @param isRecording true if recording
* @param recordingTrackPaused true if recording track is paused
*/
- private void updateRecordStatus(
+ private static void updateRecordStatus(
Context context, RemoteViews remoteViews, boolean isRecording,
boolean recordingTrackPaused) {
String status;
int colorId;
==============================================================================
Revision: 970475bced2c
Branch: default
Author: Jimmy Shih <
js...@google.com>
Date: Mon Oct 8 13:05:15 2012
Log: add 4 layout sizes for the app widget
http://code.google.com/p/mytracks/source/detail?r=970475bced2c
Added:
/MyTracks/res/layout/track_widget_4x1.xml
/MyTracks/res/layout/track_widget_4x2.xml
/MyTracks/res/layout/track_widget_4x3.xml
/MyTracks/res/layout/track_widget_4x4.xml
Deleted:
/MyTracks/res/layout/track_widget_large.xml
/MyTracks/res/layout/track_widget_small.xml
Modified:
/MyTracks/res/values/styles.xml
/MyTracks/res/xml/track_widget_info.xml
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
=======================================
--- /dev/null
+++ /MyTracks/res/layout/track_widget_4x1.xml Mon Oct 8 13:05:15 2012
@@ -0,0 +1,96 @@
+<?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.
+-->
+<RelativeLayout xmlns:android="
http://schemas.android.com/apk/res/android"
+ style="@style/TrackWidgetBoundingBox" >
+ <LinearLayout
+ android:orientation="horizontal"
+ android:paddingBottom="4dp"
+ android:paddingTop="4dp"
+ style="@style/TrackWidgetFrame" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalSpacer" />
+ <ImageButton
+ android:contentDescription="@string/icon_record_track"
+ android:id="@+id/track_widget_record_button"
+ style="@style/TrackWidgetButtonRecord" />
+ <LinearLayout
+ android:id="@+id/track_widget_stats_container"
+ android:layout_height="fill_parent"
+ android:layout_weight="18"
+ android:layout_width="0dp"
+ android:padding="0dp"
+ style="@style/TrackWidgetStatsContainer" >
+ <LinearLayout style="@style/TrackWidgetStatsSection" >
+ <!-- item1 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer" >
+ <TextView
+ android:id="@+id/track_widget_item1_label"
+ style="@style/TrackWidgetLabel" />
+ <LinearLayout style="@style/TrackWidgetValueContainer" >
+ <TextView
+ android:id="@+id/track_widget_item1_value"
+ style="@style/TrackWidgetValue" />
+ <TextView
+ android:id="@+id/track_widget_item1_unit"
+ style="@style/TrackWidgetUnit" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ <!-- horizontal separator -->
+ <LinearLayout
+ android:baselineAligned="false"
+ style="@style/TrackWidgetHorizontalSeparator" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetHorizontalSpacer" />
+ <LinearLayout
+ android:layout_weight="38"
+ style="@style/TrackWidgetHorizontalLine" />
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetHorizontalSpacer" />
+ </LinearLayout>
+ <LinearLayout style="@style/TrackWidgetStatsSection" >
+ <LinearLayout style="@style/TrackWidgetItemContainer" >
+ <!-- item2 -->
+ <TextView
+ android:id="@+id/track_widget_item2_label"
+ style="@style/TrackWidgetLabel" />
+ <LinearLayout style="@style/TrackWidgetValueContainer" >
+ <TextView
+ android:id="@+id/track_widget_item2_value"
+ style="@style/TrackWidgetValue" />
+ <TextView
+ android:id="@+id/track_widget_item2_unit"
+ style="@style/TrackWidgetUnit" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ <ImageButton
+ android:contentDescription="@string/icon_stop_recording"
+ android:id="@+id/track_widget_stop_button"
+ style="@style/TrackWidgetButtonStop" />
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalSpacer" />
+ </LinearLayout>
+ <ImageView
+ android:contentDescription="@string/my_tracks_app_name"
+ style="@style/TrackWidgetLogo" />
+</RelativeLayout>
=======================================
--- /dev/null
+++ /MyTracks/res/layout/track_widget_4x2.xml Mon Oct 8 13:05:15 2012
@@ -0,0 +1,152 @@
+<?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.
+-->
+<RelativeLayout xmlns:android="
http://schemas.android.com/apk/res/android"
+ style="@style/TrackWidgetBoundingBox" >
+ <LinearLayout
+ android:baselineAligned="false"
+ style="@style/TrackWidgetFrame" >
+ <LinearLayout
+ android:baselineAligned="false"
+ android:id="@+id/track_widget_stats_container"
+ android:layout_weight="1"
+ style="@style/TrackWidgetStatsContainer" >
+ <LinearLayout style="@style/TrackWidgetStatsSection" >
+ <!-- item1 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x2" >
+ <TextView
+ android:id="@+id/track_widget_item1_label"
+ style="@style/TrackWidgetLabel" />
+ <LinearLayout style="@style/TrackWidgetValueContainer" >
+ <TextView
+ android:id="@+id/track_widget_item1_value"
+ style="@style/TrackWidgetValue" />
+ <TextView
+ android:id="@+id/track_widget_item1_unit"
+ style="@style/TrackWidgetUnit" />
+ </LinearLayout>
+ </LinearLayout>
+ <!-- vertical separator -->
+ <LinearLayout
+ android:baselineAligned="false"
+ style="@style/TrackWidgetVerticalSeparator" >
+ <LinearLayout
+ android:layout_weight="2"
+ style="@style/TrackWidgetVerticalSpacer" />
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalLine" />
+ </LinearLayout>
+ <!-- item3 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x2" >
+ <TextView
+ android:id="@+id/track_widget_item3_label"
+ style="@style/TrackWidgetLabel" />
+ <LinearLayout style="@style/TrackWidgetValueContainer" >
+ <TextView
+ android:id="@+id/track_widget_item3_value"
+ style="@style/TrackWidgetValue" />
+ <TextView
+ android:id="@+id/track_widget_item3_unit"
+ style="@style/TrackWidgetUnit" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ <!-- horizontal separator -->
+ <LinearLayout
+ android:baselineAligned="false"
+ style="@style/TrackWidgetHorizontalSeparator" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetHorizontalSpacer" />
+ <LinearLayout
+ android:layout_weight="38"
+ style="@style/TrackWidgetHorizontalLine" />
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetHorizontalSpacer" />
+ </LinearLayout>
+ <LinearLayout style="@style/TrackWidgetStatsSection" >
+ <!-- item2 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x2" >
+ <TextView
+ android:id="@+id/track_widget_item2_label"
+ style="@style/TrackWidgetLabel" />
+ <LinearLayout style="@style/TrackWidgetValueContainer" >
+ <TextView
+ android:id="@+id/track_widget_item2_value"
+ style="@style/TrackWidgetValue" />
+ <TextView
+ android:id="@+id/track_widget_item2_unit"
+ style="@style/TrackWidgetUnit" />
+ </LinearLayout>
+ </LinearLayout>
+ <!-- vertical separator -->
+ <LinearLayout
+ android:baselineAligned="false"
+ style="@style/TrackWidgetVerticalSeparator" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalLine" />
+ <LinearLayout
+ android:layout_weight="2"
+ style="@style/TrackWidgetVerticalSpacer" />
+ </LinearLayout>
+ <!-- item4 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x2" >
+ <TextView
+ android:id="@+id/track_widget_item4_label"
+ style="@style/TrackWidgetLabel" />
+ <LinearLayout style="@style/TrackWidgetValueContainer" >
+ <TextView
+ android:id="@+id/track_widget_item4_value"
+ style="@style/TrackWidgetValue" />
+ <TextView
+ android:id="@+id/track_widget_item4_unit"
+ style="@style/TrackWidgetUnit" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ <LinearLayout style="@style/TrackWidgetButtonContainer" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalSpacer" />
+ <ImageButton
+ android:contentDescription="@string/icon_record_track"
+ android:id="@+id/track_widget_record_button"
+ style="@style/TrackWidgetButtonRecord" />
+ <TextView
+ android:id="@+id/track_widget_record_status"
+ android:layout_gravity="center_vertical"
+ android:layout_height="wrap_content"
+ android:layout_weight="2"
+ android:layout_width="0dp"
+ android:singleLine="true"
+ style="@style/TextSmall" />
+ <ImageButton
+ android:contentDescription="@string/icon_stop_recording"
+ android:id="@+id/track_widget_stop_button"
+ style="@style/TrackWidgetButtonStop" />
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalSpacer" />
+ </LinearLayout>
+ </LinearLayout>
+ <ImageView
+ android:contentDescription="@string/my_tracks_app_name"
+ style="@style/TrackWidgetLogo" />
+</RelativeLayout>
=======================================
--- /dev/null
+++ /MyTracks/res/layout/track_widget_4x3.xml Mon Oct 8 13:05:15 2012
@@ -0,0 +1,148 @@
+<?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.
+-->
+<RelativeLayout xmlns:android="
http://schemas.android.com/apk/res/android"
+ style="@style/TrackWidgetBoundingBox" >
+ <LinearLayout
+ android:baselineAligned="false"
+ style="@style/TrackWidgetFrame" >
+ <LinearLayout
+ android:baselineAligned="false"
+ android:id="@+id/track_widget_stats_container"
+ android:layout_weight="2"
+ style="@style/TrackWidgetStatsContainer" >
+ <LinearLayout style="@style/TrackWidgetStatsSection" >
+ <!-- item1 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item1_label"
+ style="@style/TrackWidgetLabel4x3" />
+ <LinearLayout style="@style/TrackWidgetValueContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item1_value"
+ style="@style/TrackWidgetValue4x3" />
+ <TextView
+ android:id="@+id/track_widget_item1_unit"
+ style="@style/TrackWidgetUnit4x3" />
+ </LinearLayout>
+ </LinearLayout>
+ <!-- vertical separator -->
+ <LinearLayout style="@style/TrackWidgetVerticalSeparator" >
+ <LinearLayout
+ android:layout_weight="2"
+ style="@style/TrackWidgetVerticalSpacer" />
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalLine" />
+ </LinearLayout>
+ <!-- item3 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item3_label"
+ style="@style/TrackWidgetLabel4x3" />
+ <LinearLayout style="@style/TrackWidgetValueContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item3_value"
+ style="@style/TrackWidgetValue4x3" />
+ <TextView
+ android:id="@+id/track_widget_item3_unit"
+ style="@style/TrackWidgetUnit4x3" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ <!-- horizontal separator -->
+ <LinearLayout
+ android:baselineAligned="false"
+ style="@style/TrackWidgetHorizontalSeparator" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetHorizontalSpacer" />
+ <LinearLayout
+ android:layout_weight="38"
+ style="@style/TrackWidgetHorizontalLine" />
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetHorizontalSpacer" />
+ </LinearLayout>
+ <LinearLayout style="@style/TrackWidgetStatsSection" >
+ <!-- item2 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item2_label"
+ style="@style/TrackWidgetLabel4x3" />
+ <LinearLayout style="@style/TrackWidgetValueContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item2_value"
+ style="@style/TrackWidgetValue4x3" />
+ <TextView
+ android:id="@+id/track_widget_item2_unit"
+ style="@style/TrackWidgetUnit4x3" />
+ </LinearLayout>
+ </LinearLayout>
+ <!-- vertical separator -->
+ <LinearLayout style="@style/TrackWidgetVerticalSeparator" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalLine" />
+ <LinearLayout
+ android:layout_weight="2"
+ style="@style/TrackWidgetVerticalSpacer" />
+ </LinearLayout>
+ <!-- item4 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item4_label"
+ style="@style/TrackWidgetLabel4x3" />
+ <LinearLayout style="@style/TrackWidgetValueContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item4_value"
+ style="@style/TrackWidgetValue4x3" />
+ <TextView
+ android:id="@+id/track_widget_item4_unit"
+ style="@style/TrackWidgetUnit4x3" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ <LinearLayout style="@style/TrackWidgetButtonContainer" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalSpacer" />
+ <ImageButton
+ android:contentDescription="@string/icon_record_track"
+ android:id="@+id/track_widget_record_button"
+ style="@style/TrackWidgetButtonRecord" />
+ <TextView
+ android:id="@+id/track_widget_record_status"
+ android:layout_gravity="center_vertical"
+ android:layout_height="wrap_content"
+ android:layout_weight="2"
+ android:layout_width="0dp"
+ android:singleLine="true"
+ style="@style/TextSmall" />
+ <ImageButton
+ android:contentDescription="@string/icon_stop_recording"
+ android:id="@+id/track_widget_stop_button"
+ style="@style/TrackWidgetButtonStop" />
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalSpacer" />
+ </LinearLayout>
+ </LinearLayout>
+ <ImageView
+ android:contentDescription="@string/my_tracks_app_name"
+ style="@style/TrackWidgetLogo" />
+</RelativeLayout>
=======================================
--- /dev/null
+++ /MyTracks/res/layout/track_widget_4x4.xml Mon Oct 8 13:05:15 2012
@@ -0,0 +1,156 @@
+<?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.
+-->
+<RelativeLayout xmlns:android="
http://schemas.android.com/apk/res/android"
+ style="@style/TrackWidgetBoundingBox" >
+ <LinearLayout
+ android:baselineAligned="false"
+ style="@style/TrackWidgetFrame" >
+ <LinearLayout
+ android:baselineAligned="false"
+ android:id="@+id/track_widget_stats_container"
+ android:layout_weight="3"
+ style="@style/TrackWidgetStatsContainer" >
+ <LinearLayout style="@style/TrackWidgetStatsSection" >
+ <!-- item1 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x4" >
+ <TextView
+ android:id="@+id/track_widget_item1_label"
+ style="@style/TrackWidgetLabel4x4" />
+ <LinearLayout style="@style/TrackWidgetValueContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item1_value"
+ style="@style/TrackWidgetValue4x4" />
+ <TextView
+ android:id="@+id/track_widget_item1_unit"
+ style="@style/TrackWidgetUnit4x4" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ <!-- horizontal separator -->
+ <LinearLayout
+ android:baselineAligned="false"
+ style="@style/TrackWidgetHorizontalSeparator" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetHorizontalSpacer" />
+ <LinearLayout
+ android:layout_weight="4"
+ style="@style/TrackWidgetHorizontalLine" />
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetHorizontalSpacer" />
+ </LinearLayout>
+ <LinearLayout style="@style/TrackWidgetStatsSection" >
+ <!-- item3 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x4" >
+ <TextView
+ android:id="@+id/track_widget_item3_label"
+ style="@style/TrackWidgetLabel4x4" />
+ <LinearLayout style="@style/TrackWidgetValueContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item3_value"
+ style="@style/TrackWidgetValue4x4" />
+ <TextView
+ android:id="@+id/track_widget_item3_unit"
+ style="@style/TrackWidgetUnit4x4" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ <LinearLayout
+ android:baselineAligned="false"
+ style="@style/TrackWidgetHorizontalSeparator" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetHorizontalSpacer" />
+ <LinearLayout
+ android:layout_weight="38"
+ style="@style/TrackWidgetHorizontalLine" />
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetHorizontalSpacer" />
+ </LinearLayout>
+ <LinearLayout style="@style/TrackWidgetStatsSection" >
+ <!-- item2 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item2_label"
+ style="@style/TrackWidgetLabel4x3" />
+ <LinearLayout style="@style/TrackWidgetValueContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item2_value"
+ style="@style/TrackWidgetValue4x3" />
+ <TextView
+ android:id="@+id/track_widget_item2_unit"
+ style="@style/TrackWidgetUnit4x3" />
+ </LinearLayout>
+ </LinearLayout>
+ <!-- vertical separator -->
+ <LinearLayout
+ android:baselineAligned="false"
+ style="@style/TrackWidgetVerticalSeparator" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalLine" />
+ <LinearLayout
+ android:layout_weight="2"
+ style="@style/TrackWidgetVerticalSpacer" />
+ </LinearLayout>
+ <!-- item4 -->
+ <LinearLayout style="@style/TrackWidgetItemContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item4_label"
+ style="@style/TrackWidgetLabel4x3" />
+ <LinearLayout style="@style/TrackWidgetValueContainer4x3" >
+ <TextView
+ android:id="@+id/track_widget_item4_value"
+ style="@style/TrackWidgetValue4x3" />
+ <TextView
+ android:id="@+id/track_widget_item4_unit"
+ style="@style/TrackWidgetUnit4x3" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ <LinearLayout style="@style/TrackWidgetButtonContainer" >
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalSpacer" />
+ <ImageButton
+ android:contentDescription="@string/icon_record_track"
+ android:id="@+id/track_widget_record_button"
+ style="@style/TrackWidgetButtonRecord" />
+ <TextView
+ android:id="@+id/track_widget_record_status"
+ android:layout_gravity="center_vertical"
+ android:layout_height="wrap_content"
+ android:layout_weight="2"
+ android:layout_width="0dp"
+ android:singleLine="true"
+ style="@style/TextSmall" />
+ <ImageButton
+ android:contentDescription="@string/icon_stop_recording"
+ android:id="@+id/track_widget_stop_button"
+ style="@style/TrackWidgetButtonStop" />
+ <LinearLayout
+ android:layout_weight="1"
+ style="@style/TrackWidgetVerticalSpacer" />
+ </LinearLayout>
+ </LinearLayout>
+ <ImageView
+ android:contentDescription="@string/my_tracks_app_name"
+ style="@style/TrackWidgetLogo4x4" />
+</RelativeLayout>
=======================================
--- /MyTracks/res/layout/track_widget_large.xml Fri Oct 5 11:26:57 2012
+++ /dev/null
@@ -1,136 +0,0 @@
-<?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.
--->
-<RelativeLayout xmlns:android="
http://schemas.android.com/apk/res/android"
- android:background="@drawable/track_widget_background"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent"
- android:padding="@dimen/widget_margin" >
- <LinearLayout
- android:layout_alignParentTop="true"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent"
- android:orientation="vertical" >
- <LinearLayout
- android:clickable="true"
- android:gravity="center_vertical"
- android:id="@+id/track_widget_statistics"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:layout_width="fill_parent"
- android:orientation="vertical"
- android:padding="4dp" >
- <LinearLayout style="@style/LinearLayoutHorizontal" >
- <!-- item1 -->
- <LinearLayout style="@style/TrackWidgetItemContainer" >
- <TextView
- android:id="@+id/track_widget_item1_label"
- style="@style/TrackWidgetLabel" />
- <LinearLayout style="@style/TrackWidgetValueContainer" >
- <TextView
- android:id="@+id/track_widget_item1_value"
- style="@style/TrackWidgetValue" />
- <TextView
- android:id="@+id/track_widget_item1_unit"
- style="@style/TrackWidgetUnit" />
- </LinearLayout>
- </LinearLayout>
- <!-- vertical separator -->
- <LinearLayout style="@style/LinearLayoutVertifcal" >
- <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
- <LinearLayout style="@style/TrackWidgetVerticalSeparator" />
- </LinearLayout>
- <!-- item3 -->
- <LinearLayout style="@style/TrackWidgetItemContainer" >
- <TextView
- android:id="@+id/track_widget_item3_label"
- style="@style/TrackWidgetLabel" />
- <LinearLayout style="@style/TrackWidgetValueContainer" >
- <TextView
- android:id="@+id/track_widget_item3_value"
- style="@style/TrackWidgetValue" />
- <TextView
- android:id="@+id/track_widget_item3_unit"
- style="@style/TrackWidgetUnit" />
- </LinearLayout>
- </LinearLayout>
- </LinearLayout>
- <!-- horizontal separator -->
- <LinearLayout style="@style/TrackWidgetHorizontalSeparator" />
- <LinearLayout style="@style/LinearLayoutHorizontal" >
- <!-- item2 -->
- <LinearLayout style="@style/TrackWidgetItemContainer" >
- <TextView
- android:id="@+id/track_widget_item2_label"
- style="@style/TrackWidgetLabel" />
- <LinearLayout style="@style/TrackWidgetValueContainer" >
- <TextView
- android:id="@+id/track_widget_item2_value"
- style="@style/TrackWidgetValue" />
- <TextView
- android:id="@+id/track_widget_item2_unit"
- style="@style/TrackWidgetUnit" />
- </LinearLayout>
- </LinearLayout>
- <!-- vertical separator -->
- <LinearLayout style="@style/LinearLayoutVertifcal" >
- <LinearLayout style="@style/TrackWidgetVerticalSeparator" />
- <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
- </LinearLayout>
- <!-- item4 -->
- <LinearLayout style="@style/TrackWidgetItemContainer" >
- <TextView
- android:id="@+id/track_widget_item4_label"
- style="@style/TrackWidgetLabel" />
- <LinearLayout style="@style/TrackWidgetValueContainer" >
- <TextView
- android:id="@+id/track_widget_item4_value"
- style="@style/TrackWidgetValue" />
- <TextView
- android:id="@+id/track_widget_item4_unit"
- style="@style/TrackWidgetUnit" />
- </LinearLayout>
- </LinearLayout>
- </LinearLayout>
- </LinearLayout>
- <LinearLayout
- android:gravity="center_vertical"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:layout_width="fill_parent"
- android:orientation="horizontal"
- android:paddingBottom="4dp"
- android:paddingTop="4dp" >
- <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
- <ImageButton
- android:id="@+id/track_widget_record_button"
- style="@style/TrackWidgetRecordButton" />
- <TextView
- android:id="@+id/track_widget_record_status"
- android:layout_gravity="center_vertical"
- android:layout_height="wrap_content"
- android:layout_weight="4"
- android:layout_width="0dp"
- android:singleLine="true"
- style="@style/TextSmall" />
- <ImageButton
- android:id="@+id/track_widget_stop_button"
- style="@style/TrackWidgetStopButton" />
- <LinearLayout style="@style/TrackWidgetVerticalSpacer" />
- </LinearLayout>
- </LinearLayout>
- <ImageView style="@style/TrackWidgetLogo" />
-</RelativeLayout>
=======================================
--- /MyTracks/res/layout/track_widget_small.xml Fri Oct 5 11:26:57 2012
+++ /dev/null
@@ -1,86 +0,0 @@
-<?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.
--->
-<RelativeLayout xmlns:android="
http://schemas.android.com/apk/res/android"
- android:background="@drawable/track_widget_background"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent"
- android:padding="@dimen/widget_margin" >
- <LinearLayout
- android:layout_alignParentTop="true"
- android:layout_height="100dp"
- android:layout_width="fill_parent"
- android:orientation="horizontal"
- android:paddingBottom="4dp"
- android:paddingLeft="12dp"
- android:paddingRight="12dp"
- android:paddingTop="4dp" >
- <ImageButton
- android:id="@+id/track_widget_record_button"
- style="@style/TrackWidgetRecordButton" />
- <LinearLayout
- android:clickable="true"
- android:id="@+id/track_widget_statistics"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:layout_width="0dp"
- android:orientation="vertical"
- android:paddingLeft="4dp"
- android:paddingRight="4dp" >
- <LinearLayout
- android:layout_height="0dp"
- android:layout_weight="1"
- android:layout_width="fill_parent"
- android:orientation="vertical" >
- <!-- item1 -->
- <TextView
- android:id="@+id/track_widget_item1_label"
- style="@style/TrackWidgetLabel" />
- <LinearLayout style="@style/TrackWidgetValueContainer" >
- <TextView
- android:id="@+id/track_widget_item1_value"
- style="@style/TrackWidgetValue" />
- <TextView
- android:id="@+id/track_widget_item1_unit"
- style="@style/TrackWidgetUnit" />
- </LinearLayout>
- </LinearLayout>
- <LinearLayout style="@style/TrackWidgetHorizontalSeparator" />
- <LinearLayout
- android:layout_height="0dp"
- android:layout_weight="1"
- android:layout_width="fill_parent"
- android:orientation="vertical" >
- <!-- item2 -->
- <TextView
- android:id="@+id/track_widget_item2_label"
- style="@style/TrackWidgetLabel" />
- <LinearLayout style="@style/TrackWidgetValueContainer" >
- <TextView
- android:id="@+id/track_widget_item2_value"
- style="@style/TrackWidgetValue" />
- <TextView
- android:id="@+id/track_widget_item2_unit"
- style="@style/TrackWidgetUnit" />
- </LinearLayout>
- </LinearLayout>
- </LinearLayout>
- <ImageButton
- android:id="@+id/track_widget_stop_button"
- style="@style/TrackWidgetStopButton" />
- </LinearLayout>
- <ImageView style="@style/TrackWidgetLogo" />
-</RelativeLayout>
=======================================
--- /MyTracks/res/values/styles.xml Fri Oct 5 11:26:57 2012
+++ /MyTracks/res/values/styles.xml Mon Oct 8 13:05:15 2012
@@ -15,44 +15,44 @@
limitations under the License.
-->
<resources xmlns:android="
http://schemas.android.com/apk/res/android">
- <!-- The style for the about value -->
+ <!-- about value -->
<style name="AboutValue" parent="@style/TextMedium">
<item name="android:paddingLeft">48dp</item>
</style>
- <!-- The style for the bottom button -->
+ <!-- bottom button -->
<style name="BottomButton"
parent="@android:style/Widget.DeviceDefault.Button.Borderless">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_width">0dp</item>
<item name="android:maxLines">2</item>
</style>
- <!-- The style for the bottom button bar -->
+ <!-- bottom button bar -->
<style name="BottomButtonBar"
parent="@android:style/DeviceDefault.ButtonBar">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:orientation">horizontal</item>
<item name="android:measureWithLargestChild">true</item>
</style>
- <!-- The style for choose upload service check box -->
+ <!-- choose upload service checkbox -->
<style name="ChooseUploadServiceCheckBox" parent="@style/TextMedium">
<item name="android:layout_gravity">center_vertical</item>
<item name="android:layout_marginLeft">8dp</item>
<item name="android:layout_width">0dp</item>
<item name="android:maxLines">5</item>
</style>
- <!-- The style for choose upload service image view -->
+ <!-- choose upload service image view -->
<style name="ChooseUploadServiceImageView">
<item name="android:layout_gravity">center</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
</style>
- <!-- The style for the editing category -->
+ <!-- edit category -->
<style name="EditCategory" parent="@style/TextMedium">
<item name="android:layout_width">fill_parent</item>
<item name="android:selectAllOnFocus">true</item>
<item name="android:singleLine">true</item>
</style>
- <!-- The style for the edit description -->
+ <!-- edit description -->
<style name="EditDescription" parent="@style/TextMedium">
<item name="android:inputType">textAutoCorrect|textCapSentences|
textMultiLine</item>
<item name="android:layout_width">fill_parent</item>
@@ -60,81 +60,69 @@
<item name="android:selectAllOnFocus">true</item>
<item name="android:singleLine">false</item>
</style>
- <!-- The style for the edit label -->
+ <!-- edit label -->
<style name="EditLabel" parent="@style/TextMedium">
<item name="android:layout_width">fill_parent</item>
</style>
- <!-- The style for the edit label with icon -->
+ <!-- edit label with icon -->
<style name="EditLabel.WithIcon" parent="@style/TextMedium.WithIcon">
<item name="android:layout_width">fill_parent</item>
</style>
- <!-- The style for the edit label with icon and with padding top -->
+ <!-- edit label with icon, width padding top -->
<style name="EditLabel.WithIcon.WithPaddingTop">
<item name="android:paddingTop">16dp</item>
</style>
- <!-- The style for the edit lable with padding top -->
+ <!-- edit label with padding top -->
<style name="EditLabel.WithPaddingTop">
<item name="android:paddingTop">16dp</item>
</style>
- <!-- The style for editing marker name -->
+ <!-- edit name marker -->
<style name="EditNameMarker" parent="@style/TextMedium.WithIcon">
<item name="android:inputType">textAutoCorrect|textCapWords</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:selectAllOnFocus">true</item>
<item name="android:singleLine">true</item>
</style>
- <!-- The style for editing track name -->
+ <!-- edit name track -->
<style name="EditNameTrack" parent="@style/TextMedium">
<item name="android:inputType">textAutoCorrect|textCapWords</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:selectAllOnFocus">true</item>
<item name="android:singleLine">true</item>
</style>
- <!-- The style for the help answer -->
+ <!-- help answer -->
<style name="HelpAnswer" parent="@style/TextSmall">
<item name="android:autoLink">web</item>
<item name="android:paddingBottom">8dp</item>
</style>
- <!-- The style for help question -->
+ <!-- help question -->
<style name="HelpQuestion" parent="@style/TextMedium">
<item name="android:paddingTop">8dp</item>
<item name="android:textStyle">bold</item>
</style>
- <!-- The style for the list empty text view -->
+ <!-- list empty text view -->
<style name="ListEmptyTextView" parent="@style/TextLarge">
<item name="android:gravity">center</item>
<item name="android:layout_gravity">center</item>
<item name="android:padding">8dp</item>
</style>
- <!-- style for the list item stats -->
+ <!-- list item stats -->
<style name="ListItemStats" parent="@style/TextSmall">
<item name="android:singleLine">true</item>
<item
name="android:textColor">@android:color/secondary_text_dark</item>
</style>
- <!-- The style for a horizontal linear layout -->
- <style name="LinearLayoutHorizontal">
- <item name="android:layout_height">wrap_content</item>
- <item name="android:layout_width">fill_parent</item>
- <item name="android:orientation">horizontal</item>
- </style>
- <!-- The style for a vertical linear layout -->
- <style name="LinearLayoutVertifcal">
- <item name="android:layout_height">fill_parent</item>
- <item name="android:layout_width">wrap_content</item>
- <item name="android:orientation">vertical</item>
- </style>
- <!-- The style for the scroll view -->
+ <!-- scroll view -->
<style name="ScrollView">
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:scrollbarStyle">outsideInset</item>
</style>
- <!-- The style for the scroll view with bottom buttons -->
+ <!-- scroll view with bottom buttons -->
<style name="ScrollView.WithBottomButtons">
<item name="android:layout_height">0dp</item>
<item name="android:layout_weight">1</item>
</style>
- <!-- The style for the sensor state value -->
+ <!-- sensor state value -->
<style name="SensorStateValue" parent="@style/TextLarge">
<item name="android:background">@android:color/background_light</item>
<item name="android:gravity">right</item>
@@ -142,17 +130,17 @@
<item name="android:paddingRight">8dp</item>
<item name="android:textColor">@android:color/primary_text_light</item>
</style>
- <!-- The style for the stats label -->
+ <!-- stats label -->
<style name="StatsLabel" parent="@style/TextMedium">
<item name="android:layout_weight">1</item>
<item name="android:layout_width">0dp</item>
</style>
- <!-- The style for the stats spacer -->
+ <!-- stats spacer -->
<style name="StatsSpacer">
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_width">8dp</item>
</style>
- <!-- The style for the stats value -->
+ <!-- stats value -->
<style name="StatsValue" parent="@style/TextLarge">
<item name="android:background">@android:color/background_light</item>
<item name="android:gravity">right</item>
@@ -161,84 +149,131 @@
<item name="android:paddingRight">8dp</item>
<item name="android:textColor">@android:color/primary_text_light</item>
</style>
- <!-- The style for choose activity text -->
+ <!-- text choose activity -->
<style name="TextChooseActivity">
<item name="android:textSize">18sp</item>
</style>
- <!-- The style for large size text -->
+ <!-- text large -->
<style name="TextLarge">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:textSize">22sp</item>
</style>
- <!-- The style for large size text with top margin -->
+ <!-- text large with top margin -->
<style name="TextLarge.WithTopMargin">
<item name="android:layout_marginTop">8dp</item>
</style>
- <!-- The style for medium size text -->
+ <!-- text medium -->
<style name="TextMedium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:textSize">18sp</item>
</style>
- <!-- The style for medium size text with an icon on the left -->
+ <!-- text medium with icon -->
<style name="TextMedium.WithIcon">
<item name="android:drawablePadding">8dp</item>
<item name="android:gravity">center_vertical</item>
</style>
- <!-- The style for small size text -->
- <style name="TextSmall">
+ <!-- text micro -->
+ <style name="TextMicro">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
- <item name="android:textSize">14sp</item>
+ <item name="android:textSize">12sp</item>
</style>
- <!-- The style for micro size text -->
- <style name="TextMicro">
+ <!-- text small -->
+ <style name="TextSmall">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
- <item name="android:textSize">12sp</item>
+ <item name="android:textSize">14sp</item>
</style>
- <!-- Theme selector -->
+ <!-- theme selector -->
<style name="ThemeSelector" parent="android:Theme" />
- <!-- The style for the track controller container -->
+ <!-- track controller container -->
<style name="TrackControllerContainer">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:orientation">vertical</item>
</style>
- <!-- The style for the track widget button -->
+ <!-- track widget bounding box -->
+ <style name="TrackWidgetBoundingBox">
+ <item
name="android:background">@drawable/track_widget_background</item>
+ <item name="android:layout_height">fill_parent</item>
+ <item name="android:layout_width">fill_parent</item>
+ <item name="android:padding">@dimen/widget_margin</item>
+ </style>
+ <!-- track widget button -->
<style name="TrackWidgetButton">
<item name="android:background">@android:color/transparent</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="android:scaleType">fitXY</item>
</style>
- <!-- The style for the track widget config row -->
+ <!-- track widget button container -->
+ <style name="TrackWidgetButtonContainer">
+ <item name="android:gravity">center_vertical</item>
+ <item name="android:layout_height">0dp</item>
+ <item name="android:layout_weight">1</item>
+ <item name="android:layout_width">fill_parent</item>
+ <item name="android:orientation">horizontal</item>
+ <item name="android:paddingBottom">4dp</item>
+ <item name="android:paddingTop">4dp</item>
+ </style>
+ <!-- track widget button record -->
+ <style name="TrackWidgetButtonRecord" parent="@style/TrackWidgetButton">
+ <item name="android:layout_height">63dp</item>
+ <item name="android:layout_width">75dp</item>
+ <item name="android:src">@drawable/btn_record</item>
+ </style>
+ <!-- track widget button stop -->
+ <style name="TrackWidgetButtonStop" parent="@style/TrackWidgetButton">
+ <item name="android:layout_height">63dp</item>
+ <item name="android:layout_width">63dp</item>
+ <item name="android:src">@drawable/btn_stop_0</item>
+ </style>
+ <!-- track widget config row -->
<style name="TrackWidgetConfigRow">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
+ <item name="android:paddingBottom">16dp</item>
<item name="android:paddingTop">16dp</item>
- <item name="android:paddingBottom">16dp</item>
</style>
- <!-- The style for the track widget config spacer -->
+ <!-- track widget config spacer -->
<style name="TrackWidgetConfigSpacer">
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">2</item>
<item name="android:layout_width">0dp</item>
</style>
- <!-- The style for the track widget config spiner -->
+ <!-- track widget config spiner -->
<style name="TrackWidgetConfigSpinner">
<item name="android:gravity">left</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">9</item>
<item name="android:layout_width">0dp</item>
</style>
- <!-- The style for the track widget horizontal separator -->
- <style name="TrackWidgetHorizontalSeparator">
+ <!-- Track widget frame -->
+ <style name="TrackWidgetFrame">
+ <item name="android:layout_alignParentTop">true</item>
+ <item name="android:layout_height">fill_parent</item>
+ <item name="android:layout_width">fill_parent</item>
+ <item name="android:orientation">vertical</item>
+ </style>
+ <!-- track widget horizontal line -->
+ <style name="TrackWidgetHorizontalLine">
<item name="android:background">@color/track_widget_line</item>
<item name="android:layout_height">1dp</item>
+ <item name="android:layout_width">0dp</item>
+ </style>
+ <!-- track widget horizontal spacer -->
+ <style name="TrackWidgetHorizontalSpacer">
+ <item name="android:layout_height">1dp</item>
+ <item name="android:layout_width">0dp</item>
+ </style>
+ <!-- track widget horizontal separator -->
+ <style name="TrackWidgetHorizontalSeparator">
+ <item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
+ <item name="android:orientation">horizontal</item>
</style>
- <!-- The style for the track widget item container -->
+ <!-- track widget item container -->
<style name="TrackWidgetItemContainer">
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:layout_height">wrap_content</item>
@@ -248,7 +283,22 @@
<item name="android:paddingBottom">2dp</item>
<item name="android:paddingTop">2dp</item>
</style>
- <!-- The style for the track widget label -->
+ <!-- track widget item container 4x2 -->
+ <style name="TrackWidgetItemContainer4x2"
parent="@style/TrackWidgetItemContainer">
+ <item name="android:paddingBottom">4dp</item>
+ <item name="android:paddingTop">4dp</item>
+ </style>
+ <!-- track widget item container 4x3 -->
+ <style name="TrackWidgetItemContainer4x3"
parent="@style/TrackWidgetItemContainer">
+ <item name="android:paddingBottom">6dp</item>
+ <item name="android:paddingTop">12dp</item>
+ </style>
+ <!-- track widget item container 4x4 -->
+ <style name="TrackWidgetItemContainer4x4"
parent="@style/TrackWidgetItemContainer">
+ <item name="android:paddingBottom">12dp</item>
+ <item name="android:paddingTop">12dp</item>
+ </style>
+ <!-- track widget label -->
<style name="TrackWidgetLabel">
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:layout_height">wrap_content</item>
@@ -259,8 +309,16 @@
<item name="android:textSize">10dp</item>
<item name="android:textStyle">bold</item>
</style>
+ <!-- track widget label 4x3 -->
+ <style name="TrackWidgetLabel4x3" parent="@style/TrackWidgetLabel">
+ <item name="android:textSize">14dp</item>
+ </style>
+ <!-- track widget label 4x4 -->
+ <style name="TrackWidgetLabel4x4" parent="@style/TrackWidgetLabel">
+ <item name="android:textSize">18dp</item>
+ </style>
+ <!-- track widget logo -->
<style name="TrackWidgetLogo">
- <item
name="android:contentDescription">@string/my_tracks_app_name</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_alignParentTop">true</item>
<item name="android:layout_height">24dp</item>
@@ -269,21 +327,28 @@
<item name="android:scaleType">fitXY</item>
<item name="android:src">@drawable/my_tracks_icon</item>
</style>
- <!-- The style for the track widget record button -->
- <style name="TrackWidgetRecordButton" parent="@style/TrackWidgetButton">
- <item
name="android:contentDescription">@string/icon_record_track</item>
- <item name="android:layout_height">63dp</item>
- <item name="android:layout_width">75dp</item>
- <item name="android:src">@drawable/btn_record</item>
+ <!-- track widget logo 4x4 -->
+ <style name="TrackWidgetLogo4x4" parent="@style/TrackWidgetLogo">
+ <item name="android:layout_height">30dp</item>
+ <item name="android:layout_width">30dp</item>
+ </style>
+ <!-- track widget stats container -->
+ <style name="TrackWidgetStatsContainer">
+ <item name="android:clickable">true</item>
+ <item name="android:layout_height">0dp</item>
+ <item name="android:layout_width">fill_parent</item>
+ <item name="android:orientation">vertical</item>
+ <item name="android:padding">4dp</item>
</style>
- <!-- The style for the track widget stop button -->
- <style name="TrackWidgetStopButton" parent="@style/TrackWidgetButton">
- <item
name="android:contentDescription">@string/icon_stop_recording</item>
- <item name="android:layout_height">63dp</item>
- <item name="android:layout_width">63dp</item>
- <item name="android:src">@drawable/btn_stop_0</item>
+ <!-- track widget stats section -->
+ <style name="TrackWidgetStatsSection">
+ <item name="android:gravity">center_vertical</item>
+ <item name="android:layout_height">0dp</item>
+ <item name="android:layout_weight">1</item>
+ <item name="android:layout_width">fill_parent</item>
+ <item name="android:orientation">horizontal</item>
</style>
- <!-- The style for the track widget unit -->
+ <!-- track widget unit -->
<style name="TrackWidgetUnit">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
@@ -292,7 +357,15 @@
<item name="android:singleLine">true</item>
<item name="android:textSize">10dp</item>
</style>
- <!-- The style for the track widget value -->
+ <!-- track widget unit 4x3 -->
+ <style name="TrackWidgetUnit4x3" parent="@style/TrackWidgetUnit">
+ <item name="android:textSize">14dp</item>
+ </style>
+ <!-- track widget unit 4x4 -->
+ <style name="TrackWidgetUnit4x4" parent="@style/TrackWidgetUnit">
+ <item name="android:textSize">18dp</item>
+ </style>
+ <!-- track widget value -->
<style name="TrackWidgetValue" parent="@style/TextMedium">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">2</item>
@@ -301,7 +374,15 @@
<item name="android:textColor">@android:color/white</item>
<item name="android:textStyle">bold</item>
</style>
- <!-- The style for the track widget value container -->
+ <!-- track widget value 4x3 -->
+ <style name="TrackWidgetValue4x3" parent="@style/TrackWidgetValue">
+ <item name="android:textSize">28sp</item>
+ </style>
+ <!-- track widget value 4x4 -->
+ <style name="TrackWidgetValue4x4" parent="@style/TrackWidgetValue">
+ <item name="android:textSize">36sp</item>
+ </style>
+ <!-- track widget value container -->
<style name="TrackWidgetValueContainer">
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:layout_height">wrap_content</item>
@@ -309,17 +390,25 @@
<item name="android:layout_width">wrap_content</item>
<item name="android:orientation">horizontal</item>
</style>
- <!-- The style for the track widget vertical separator -->
- <style name="TrackWidgetVerticalSeparator">
+ <!-- track widget value container 4x3 -->
+ <style name="TrackWidgetValueContainer4x3"
parent="@style/TrackWidgetValueContainer">
+ <item name="android:layout_marginTop">0dp</item>
+ </style>
+ <!-- track widget vertical line -->
+ <style name="TrackWidgetVerticalLine">
<item name="android:background">@color/track_widget_line</item>
<item name="android:layout_height">0dp</item>
- <item name="android:layout_weight">1</item>
<item name="android:layout_width">1dp</item>
</style>
- <!-- The style for the track widget vertical spacer -->
+ <!-- track widget vertical spacer -->
<style name="TrackWidgetVerticalSpacer">
<item name="android:layout_height">0dp</item>
- <item name="android:layout_weight">2</item>
<item name="android:layout_width">1dp</item>
</style>
+ <!-- track widget vertical separator -->
+ <style name="TrackWidgetVerticalSeparator">
+ <item name="android:layout_height">fill_parent</item>
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:orientation">vertical</item>
+ </style>
</resources>
=======================================
--- /MyTracks/res/xml/track_widget_info.xml Fri Oct 5 11:26:57 2012
+++ /MyTracks/res/xml/track_widget_info.xml Mon Oct 8 13:05:15 2012
@@ -16,7 +16,7 @@
-->
<appwidget-provider
xmlns:android="
http://schemas.android.com/apk/res/android"
android:configure="com.google.android.apps.mytracks.widgets.TrackWidgetConfigActivity"
- android:initialLayout="@layout/track_widget_large"
+ android:initialLayout="@layout/track_widget_4x2"
android:minHeight="110dp"
android:minResizeHeight="40dp"
android:minResizeWidth="250dp"
=======================================
---
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
Fri Oct 5 11:26:57 2012
+++
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
Mon Oct 8 13:05:15 2012
@@ -36,7 +36,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.TaskStackBuilder;
-import android.util.SparseBooleanArray;
+import android.util.SparseIntArray;
import android.view.View;
import android.widget.RemoteViews;
@@ -50,9 +50,13 @@
*/
public class TrackWidgetProvider extends AppWidgetProvider {
- private static final int LARGE_HEIGHT = 110;
- // Array of appwidget id to use large size
- private static final SparseBooleanArray useLargeSize = new
SparseBooleanArray();
+ private static final int TWO_CELLS = 110;
+ private static final int THREE_CELLS = 180;
+ private static final int FOUR_CELLS = 250;
+
+ // Array of appwidget id to height size in cells
+ private static final SparseIntArray HEIGHT_SIZE = new SparseIntArray();
+ private static final int DEFAULT_HEIGHT = 2;
@Override
public void onReceive(Context context, Intent intent) {
@@ -70,7 +74,7 @@
new ComponentName(context, TrackWidgetProvider.class));
for (int appWidgetId : appWidgetIds) {
RemoteViews remoteViews = getRemoteViews(
- context, trackId, useLargeSize.get(appWidgetId, true));
+ context, trackId, HEIGHT_SIZE.get(appWidgetId,
DEFAULT_HEIGHT));
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
}
@@ -80,10 +84,23 @@
@Override
public void onAppWidgetOptionsChanged(
Context context, AppWidgetManager appWidgetManager, int appWidgetId,
Bundle newOptions) {
- boolean large = newOptions == null
- || newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT)
>= LARGE_HEIGHT;
- useLargeSize.put(appWidgetId, large);
- RemoteViews remoteViews = getRemoteViews(context, -1L, large);
+ int heightSize;
+ if (newOptions == null) {
+ heightSize = 2;
+ } else {
+ int height =
newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
+ if (height >= FOUR_CELLS) {
+ heightSize = 4;
+ } else if (height >= THREE_CELLS) {
+ heightSize = 3;
+ } else if (height >= TWO_CELLS) {
+ heightSize = 2;
+ } else {
+ heightSize = 1;
+ }
+ }
+ HEIGHT_SIZE.put(appWidgetId, heightSize);
+ RemoteViews remoteViews = getRemoteViews(context, -1L, heightSize);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
@@ -96,7 +113,8 @@
*/
public static void updateAppWidget(
Context context, AppWidgetManager appWidgetManager, int appWidgetId)
{
- RemoteViews remoteViews = getRemoteViews(context, -1L,
useLargeSize.get(appWidgetId, true));
+ RemoteViews remoteViews = getRemoteViews(
+ context, -1L, HEIGHT_SIZE.get(appWidgetId, DEFAULT_HEIGHT));
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
@@ -105,11 +123,28 @@
*
* @param context the context
* @param trackId the track id
- * @param large true to use the large layout
+ * @param heightSize the layout height size
*/
- private static RemoteViews getRemoteViews(Context context, long trackId,
boolean large) {
- RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
- large ? R.layout.track_widget_large : R.layout.track_widget_small);
+ private static RemoteViews getRemoteViews(Context context, long trackId,
int heightSize) {
+ int layout;
+ switch (heightSize) {
+ case 4:
+ layout = R.layout.track_widget_4x4;
+ break;
+ case 3:
+ layout = R.layout.track_widget_4x3;
+ break;
+ case 2:
+ layout = R.layout.track_widget_4x2;
+ break;
+ case 1:
+ layout = R.layout.track_widget_4x1;
+ break;
+ default:
+ layout = R.layout.track_widget_4x2;
+ break;
+ }
+ RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
layout);
// Get the preferences
long recordingTrackId = PreferencesUtils.getLong(context,
R.string.recording_track_id_key);
@@ -142,7 +177,7 @@
updateRecordButton(context, remoteViews, isRecording,
recordingTrackPaused);
updateStopButton(context, remoteViews, isRecording);
- if (large) {
+ if (heightSize > 1) {
int item3 = PreferencesUtils.getInt(
context, R.string.track_widget_item3,
PreferencesUtils.TRACK_WIDGET_ITEM3_DEFAULT);
int item4 = PreferencesUtils.getInt(
@@ -214,7 +249,7 @@
TaskStackBuilder taskStackBuilder = TaskStackBuilder.from(context);
taskStackBuilder.addNextIntent(intent);
PendingIntent pendingIntent = taskStackBuilder.getPendingIntent(0, 0);
- remoteViews.setOnClickPendingIntent(R.id.track_widget_statistics,
pendingIntent);
+ remoteViews.setOnClickPendingIntent(R.id.track_widget_stats_container,
pendingIntent);
}
/**
==============================================================================
Revision: ad1cde9dc398
Branch: default
Author: Jimmy Shih <
js...@google.com>
Date: Mon Oct 8 15:22:39 2012
Log: update app widget style
http://code.google.com/p/mytracks/source/detail?r=ad1cde9dc398
Modified:
/MyTracks/res/drawable-mdpi/track_widget_background.9.png
/MyTracks/res/layout/track_widget_4x4.xml
/MyTracks/res/values/styles.xml
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
=======================================
--- /MyTracks/res/drawable-mdpi/track_widget_background.9.png Thu Jun 28
12:50:19 2012
+++ /MyTracks/res/drawable-mdpi/track_widget_background.9.png Mon Oct 8
15:22:39 2012
Binary file, no diff available.
=======================================
--- /MyTracks/res/layout/track_widget_4x4.xml Mon Oct 8 13:05:15 2012
+++ /MyTracks/res/layout/track_widget_4x4.xml Mon Oct 8 15:22:39 2012
@@ -29,7 +29,7 @@
<LinearLayout style="@style/TrackWidgetItemContainer4x4" >
<TextView
android:id="@+id/track_widget_item1_label"
- style="@style/TrackWidgetLabel4x4" />
+ style="@style/TrackWidgetLabel4x3" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3" >
<TextView
android:id="@+id/track_widget_item1_value"
@@ -59,7 +59,7 @@
<LinearLayout style="@style/TrackWidgetItemContainer4x4" >
<TextView
android:id="@+id/track_widget_item3_label"
- style="@style/TrackWidgetLabel4x4" />
+ style="@style/TrackWidgetLabel4x3" />
<LinearLayout style="@style/TrackWidgetValueContainer4x3" >
<TextView
android:id="@+id/track_widget_item3_value"
=======================================
--- /MyTracks/res/values/styles.xml Mon Oct 8 13:05:15 2012
+++ /MyTracks/res/values/styles.xml Mon Oct 8 15:22:39 2012
@@ -313,10 +313,6 @@
<style name="TrackWidgetLabel4x3" parent="@style/TrackWidgetLabel">
<item name="android:textSize">14dp</item>
</style>
- <!-- track widget label 4x4 -->
- <style name="TrackWidgetLabel4x4" parent="@style/TrackWidgetLabel">
- <item name="android:textSize">18dp</item>
- </style>
<!-- track widget logo -->
<style name="TrackWidgetLogo">
<item name="android:layout_alignParentRight">true</item>
@@ -392,7 +388,7 @@
</style>
<!-- track widget value container 4x3 -->
<style name="TrackWidgetValueContainer4x3"
parent="@style/TrackWidgetValueContainer">
- <item name="android:layout_marginTop">0dp</item>
+ <item name="android:layout_marginTop">-2dp</item>
</style>
<!-- track widget vertical line -->
<style name="TrackWidgetVerticalLine">
=======================================
---
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
Mon Oct 8 13:05:15 2012
+++
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
Mon Oct 8 15:22:39 2012
@@ -56,7 +56,7 @@
// Array of appwidget id to height size in cells
private static final SparseIntArray HEIGHT_SIZE = new SparseIntArray();
- private static final int DEFAULT_HEIGHT = 2;
+ private static final int DEFAULT_SIZE = 2;
@Override
public void onReceive(Context context, Intent intent) {
@@ -74,7 +74,7 @@
new ComponentName(context, TrackWidgetProvider.class));
for (int appWidgetId : appWidgetIds) {
RemoteViews remoteViews = getRemoteViews(
- context, trackId, HEIGHT_SIZE.get(appWidgetId,
DEFAULT_HEIGHT));
+ context, trackId, HEIGHT_SIZE.get(appWidgetId, DEFAULT_SIZE));
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
}
@@ -84,24 +84,24 @@
@Override
public void onAppWidgetOptionsChanged(
Context context, AppWidgetManager appWidgetManager, int appWidgetId,
Bundle newOptions) {
- int heightSize;
- if (newOptions == null) {
- heightSize = 2;
- } else {
+ if (newOptions != null) {
+ int size;
int height =
newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
- if (height >= FOUR_CELLS) {
- heightSize = 4;
+ if (height == 0) {
+ size = 2;
+ } else if (height >= FOUR_CELLS) {
+ size = 4;
} else if (height >= THREE_CELLS) {
- heightSize = 3;
+ size = 3;
} else if (height >= TWO_CELLS) {
- heightSize = 2;
+ size = 2;
} else {
- heightSize = 1;
+ size = 1;
}
+ HEIGHT_SIZE.put(appWidgetId, size);
+ RemoteViews remoteViews = getRemoteViews(context, -1L, size);
+ appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
- HEIGHT_SIZE.put(appWidgetId, heightSize);
- RemoteViews remoteViews = getRemoteViews(context, -1L, heightSize);
- appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
/**
@@ -114,7 +114,7 @@
public static void updateAppWidget(
Context context, AppWidgetManager appWidgetManager, int appWidgetId)
{
RemoteViews remoteViews = getRemoteViews(
- context, -1L, HEIGHT_SIZE.get(appWidgetId, DEFAULT_HEIGHT));
+ context, -1L, HEIGHT_SIZE.get(appWidgetId, DEFAULT_SIZE));
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
==============================================================================
Revision: 481b7b2ee0b0
Branch: default
Author: Jimmy Shih <
js...@google.com>
Date: Mon Oct 8 17:25:27 2012
Log: add chronometer to each app widget item
http://code.google.com/p/mytracks/source/detail?r=481b7b2ee0b0
Modified:
/MyTracks/res/layout/track_widget_4x1.xml
/MyTracks/res/layout/track_widget_4x2.xml
/MyTracks/res/layout/track_widget_4x3.xml
/MyTracks/res/layout/track_widget_4x4.xml
/MyTracks/res/layout/track_widget_config.xml
/MyTracks/res/values/styles.xml
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
=======================================
--- /MyTracks/res/layout/track_widget_4x1.xml Mon Oct 8 13:05:15 2012
+++ /MyTracks/res/layout/track_widget_4x1.xml Mon Oct 8 17:25:27 2012
@@ -48,6 +48,9 @@
<TextView
android:id="@+id/track_widget_item1_unit"
style="@style/TrackWidgetUnit" />
+ <Chronometer
+ android:id="@+id/track_widget_item1_chronometer"
+ style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
@@ -78,6 +81,9 @@
<TextView
android:id="@+id/track_widget_item2_unit"
style="@style/TrackWidgetUnit" />
+ <Chronometer
+ android:id="@+id/track_widget_item2_chronometer"
+ style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
=======================================
--- /MyTracks/res/layout/track_widget_4x2.xml Mon Oct 8 13:05:15 2012
+++ /MyTracks/res/layout/track_widget_4x2.xml Mon Oct 8 17:25:27 2012
@@ -37,6 +37,9 @@
<TextView
android:id="@+id/track_widget_item1_unit"
style="@style/TrackWidgetUnit" />
+ <Chronometer
+ android:id="@+id/track_widget_item1_chronometer"
+ style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
<!-- vertical separator -->
@@ -62,6 +65,9 @@
<TextView
android:id="@+id/track_widget_item3_unit"
style="@style/TrackWidgetUnit" />
+ <Chronometer
+ android:id="@+id/track_widget_item3_chronometer"
+ style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
@@ -92,6 +98,9 @@
<TextView
android:id="@+id/track_widget_item2_unit"
style="@style/TrackWidgetUnit" />
+ <Chronometer
+ android:id="@+id/track_widget_item2_chronometer"
+ style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
<!-- vertical separator -->
@@ -117,6 +126,9 @@
<TextView
android:id="@+id/track_widget_item4_unit"
style="@style/TrackWidgetUnit" />
+ <Chronometer
+ android:id="@+id/track_widget_item4_chronometer"
+ style="@style/TrackWidgetValue" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
=======================================
--- /MyTracks/res/layout/track_widget_4x3.xml Mon Oct 8 13:05:15 2012
+++ /MyTracks/res/layout/track_widget_4x3.xml Mon Oct 8 17:25:27 2012
@@ -37,6 +37,9 @@
<TextView
android:id="@+id/track_widget_item1_unit"
style="@style/TrackWidgetUnit4x3" />
+ <Chronometer
+ android:id="@+id/track_widget_item1_chronometer"
+ style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
<!-- vertical separator -->
@@ -60,6 +63,9 @@
<TextView
android:id="@+id/track_widget_item3_unit"
style="@style/TrackWidgetUnit4x3" />
+ <Chronometer
+ android:id="@+id/track_widget_item3_chronometer"
+ style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
@@ -90,6 +96,9 @@
<TextView
android:id="@+id/track_widget_item2_unit"
style="@style/TrackWidgetUnit4x3" />
+ <Chronometer
+ android:id="@+id/track_widget_item2_chronometer"
+ style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
<!-- vertical separator -->
@@ -113,6 +122,9 @@
<TextView
android:id="@+id/track_widget_item4_unit"
style="@style/TrackWidgetUnit4x3" />
+ <Chronometer
+ android:id="@+id/track_widget_item4_chronometer"
+ style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
=======================================
--- /MyTracks/res/layout/track_widget_4x4.xml Mon Oct 8 15:22:39 2012
+++ /MyTracks/res/layout/track_widget_4x4.xml Mon Oct 8 17:25:27 2012
@@ -37,6 +37,9 @@
<TextView
android:id="@+id/track_widget_item1_unit"
style="@style/TrackWidgetUnit4x4" />
+ <Chronometer
+ android:id="@+id/track_widget_item1_chronometer"
+ style="@style/TrackWidgetValue4x4" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
@@ -67,6 +70,9 @@
<TextView
android:id="@+id/track_widget_item3_unit"
style="@style/TrackWidgetUnit4x4" />
+ <Chronometer
+ android:id="@+id/track_widget_item3_chronometer"
+ style="@style/TrackWidgetValue4x4" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
@@ -96,6 +102,9 @@
<TextView
android:id="@+id/track_widget_item2_unit"
style="@style/TrackWidgetUnit4x3" />
+ <Chronometer
+ android:id="@+id/track_widget_item2_chronometer"
+ style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
<!-- vertical separator -->
@@ -121,6 +130,9 @@
<TextView
android:id="@+id/track_widget_item4_unit"
style="@style/TrackWidgetUnit4x3" />
+ <Chronometer
+ android:id="@+id/track_widget_item4_chronometer"
+ style="@style/TrackWidgetValue4x3" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
=======================================
--- /MyTracks/res/layout/track_widget_config.xml Fri Oct 5 11:26:57 2012
+++ /MyTracks/res/layout/track_widget_config.xml Mon Oct 8 17:25:27 2012
@@ -22,21 +22,24 @@
<TableLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
- android:padding="8dp" >
+ android:padding="8dp"
+ android:stretchColumns="0" >
<TableRow style="@style/TrackWidgetConfigRow" >
<Spinner
android:id="@+id/track_widget_config_item1"
style="@style/TrackWidgetConfigSpinner" />
- <LinearLayout style="@style/TrackWidgetConfigSpacer" />
+ </TableRow>
+ <TableRow style="@style/TrackWidgetConfigRow" >
<Spinner
- android:id="@+id/track_widget_config_item3"
+ android:id="@+id/track_widget_config_item2"
style="@style/TrackWidgetConfigSpinner" />
</TableRow>
<TableRow style="@style/TrackWidgetConfigRow" >
<Spinner
- android:id="@+id/track_widget_config_item2"
+ android:id="@+id/track_widget_config_item3"
style="@style/TrackWidgetConfigSpinner" />
- <LinearLayout style="@style/TrackWidgetConfigSpacer" />
+ </TableRow>
+ <TableRow style="@style/TrackWidgetConfigRow" >
<Spinner
android:id="@+id/track_widget_config_item4"
style="@style/TrackWidgetConfigSpinner" />
=======================================
--- /MyTracks/res/values/styles.xml Mon Oct 8 15:22:39 2012
+++ /MyTracks/res/values/styles.xml Mon Oct 8 17:25:27 2012
@@ -231,23 +231,14 @@
</style>
<!-- track widget config row -->
<style name="TrackWidgetConfigRow">
- <item name="android:layout_height">wrap_content</item>
- <item name="android:layout_width">wrap_content</item>
- <item name="android:paddingBottom">16dp</item>
- <item name="android:paddingTop">16dp</item>
- </style>
- <!-- track widget config spacer -->
- <style name="TrackWidgetConfigSpacer">
- <item name="android:layout_height">fill_parent</item>
- <item name="android:layout_weight">2</item>
- <item name="android:layout_width">0dp</item>
+ <item name="android:paddingBottom">20dp</item>
+ <item name="android:paddingTop">20dp</item>
</style>
<!-- track widget config spiner -->
<style name="TrackWidgetConfigSpinner">
- <item name="android:gravity">left</item>
+ <item name="android:layout_gravity">center_horizontal</item>
<item name="android:layout_height">wrap_content</item>
- <item name="android:layout_weight">9</item>
- <item name="android:layout_width">0dp</item>
+ <item name="android:layout_width">fill_parent</item>
</style>
<!-- Track widget frame -->
<style name="TrackWidgetFrame">
=======================================
---
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
Mon Oct 8 15:22:39 2012
+++
/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java
Mon Oct 8 17:25:27 2012
@@ -35,6 +35,7 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.os.SystemClock;
import android.support.v4.app.TaskStackBuilder;
import android.util.SparseIntArray;
import android.view.View;
@@ -58,6 +59,19 @@
private static final SparseIntArray HEIGHT_SIZE = new SparseIntArray();
private static final int DEFAULT_SIZE = 2;
+ private static final int[] ITEM1_IDS = { R.id.track_widget_item1_label,
+ R.id.track_widget_item1_value, R.id.track_widget_item1_unit,
+ R.id.track_widget_item1_chronometer };
+ private static final int[] ITEM2_IDS = { R.id.track_widget_item2_label,
+ R.id.track_widget_item2_value, R.id.track_widget_item2_unit,
+ R.id.track_widget_item2_chronometer };
+ private static final int[] ITEM3_IDS = { R.id.track_widget_item3_label,
+ R.id.track_widget_item3_value, R.id.track_widget_item3_unit,
+ R.id.track_widget_item3_chronometer };
+ private static final int[] ITEM4_IDS = { R.id.track_widget_item4_label,
+ R.id.track_widget_item4_value, R.id.track_widget_item4_unit,
+ R.id.track_widget_item4_chronometer };
+
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
@@ -68,7 +82,6 @@
||
context.getString(R.string.track_stopped_broadcast_action).equals(action)
||
context.getString(R.string.track_update_broadcast_action).equals(action)) {
long trackId =
intent.getLongExtra(context.getString(R.string.track_id_broadcast_extra),
-1L);
-
AppWidgetManager appWidgetManager =
AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
new ComponentName(context, TrackWidgetProvider.class));
@@ -149,8 +162,8 @@
// Get the preferences
long recordingTrackId = PreferencesUtils.getLong(context,
R.string.recording_track_id_key);
boolean isRecording = recordingTrackId !=
PreferencesUtils.RECORDING_TRACK_ID_DEFAULT;
- boolean recordingTrackPaused = PreferencesUtils.getBoolean(context,
- R.string.recording_track_paused_key,
PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
+ boolean isPaused = PreferencesUtils.getBoolean(context,
R.string.recording_track_paused_key,
+ PreferencesUtils.RECORDING_TRACK_PAUSED_DEFAULT);
boolean metricUnits = PreferencesUtils.getBoolean(
context, R.string.metric_units_key,
PreferencesUtils.METRIC_UNITS_DEFAULT);
boolean reportSpeed = PreferencesUtils.getBoolean(
@@ -170,23 +183,23 @@
TripStatistics tripStatistics = track == null ? null :
track.getTripStatistics();
updateStatisticsContainer(context, remoteViews, track);
- setItem(context, remoteViews, R.id.track_widget_item1_label,
R.id.track_widget_item1_value,
- R.id.track_widget_item1_unit, item1, tripStatistics, metricUnits,
reportSpeed);
- setItem(context, remoteViews, R.id.track_widget_item2_label,
R.id.track_widget_item2_value,
- R.id.track_widget_item2_unit, item2, tripStatistics, metricUnits,
reportSpeed);
+ setItem(context, remoteViews, ITEM1_IDS, item1, tripStatistics,
isRecording, isPaused,
+ metricUnits, reportSpeed);
+ setItem(context, remoteViews, ITEM2_IDS, item2, tripStatistics,
isRecording, isPaused,
+ metricUnits, reportSpeed);
- updateRecordButton(context, remoteViews, isRecording,
recordingTrackPaused);
+ updateRecordButton(context, remoteViews, isRecording, isPaused);
updateStopButton(context, remoteViews, isRecording);
if (heightSize > 1) {
int item3 = PreferencesUtils.getInt(
context, R.string.track_widget_item3,
PreferencesUtils.TRACK_WIDGET_ITEM3_DEFAULT);
int item4 = PreferencesUtils.getInt(
context, R.string.track_widget_item4,
PreferencesUtils.TRACK_WIDGET_ITEM4_DEFAULT);
- setItem(context, remoteViews, R.id.track_widget_item3_label,
R.id.track_widget_item3_value,
- R.id.track_widget_item3_unit, item3, tripStatistics,
metricUnits, reportSpeed);
- setItem(context, remoteViews, R.id.track_widget_item4_label,
R.id.track_widget_item4_value,
- R.id.track_widget_item4_unit, item4, tripStatistics,
metricUnits, reportSpeed);
- updateRecordStatus(context, remoteViews, isRecording,
recordingTrackPaused);
+ setItem(context, remoteViews, ITEM3_IDS, item3, tripStatistics,
isRecording, isPaused,
+ metricUnits, reportSpeed);
+ setItem(context, remoteViews, ITEM4_IDS, item4, tripStatistics,
isRecording, isPaused,
+ metricUnits, reportSpeed);
+ updateRecordStatus(context, remoteViews, isRecording, isPaused);
}
return remoteViews;
}
@@ -196,37 +209,42 @@
*
* @param context the context
* @param remoteViews the remote view
- * @param labelId the label id
- * @param valueId the value id
- * @param unitId the unit id
- * @param itemValue the item value
+ * @param ids the item's ids
+ * @param value the item value
* @param tripStatistics the trip statistics
* @param metricUnits true to use metric units
* @param reportSpeed try to report speed
*/
- private static void setItem(Context context, RemoteViews remoteViews,
int labelId, int valueId,
- int unitId, int itemValue, TripStatistics tripStatistics, boolean
metricUnits,
+ private static void setItem(Context context, RemoteViews remoteViews,
int[] ids, int value,
+ TripStatistics tripStatistics, boolean isRecording, boolean
isPaused, boolean metricUnits,
boolean reportSpeed) {
- switch (itemValue) {
+ switch (value) {
+ case 0:
+ updateTotalDistance(context, remoteViews, ids, tripStatistics,
metricUnits);
+ break;
case 1:
- updateTotalTime(context, remoteViews, labelId, valueId, unitId,
tripStatistics);
+ updateTotalTime(context, remoteViews, ids, tripStatistics,
isRecording, isPaused);
break;
case 2:
- updateAverageSpeed(context, remoteViews, labelId, valueId, unitId,
tripStatistics,
- metricUnits, reportSpeed);
+ updateAverageSpeed(context, remoteViews, ids, tripStatistics,
metricUnits, reportSpeed);
break;
case 3:
- updateMovingTime(context, remoteViews, labelId, valueId, unitId,
tripStatistics);
+ updateMovingTime(context, remoteViews, ids, tripStatistics);
break;
case 4:
- updateAverageMovingSpeed(context, remoteViews, labelId, valueId,
unitId, tripStatistics,
- metricUnits, reportSpeed);
+ updateAverageMovingSpeed(
+ context, remoteViews, ids, tripStatistics, metricUnits,
reportSpeed);
break;
- case 0:
default:
- updateTotalDistance(
- context, remoteViews, labelId, valueId, unitId,
tripStatistics, metricUnits);
+ updateTotalDistance(context, remoteViews, ids, tripStatistics,
metricUnits);
break;
+
+ }
+ if (value != 1) {
+ remoteViews.setViewVisibility(ids[1], View.VISIBLE);
+ remoteViews.setViewVisibility(ids[2], View.VISIBLE);
+ remoteViews.setViewVisibility(ids[3], View.GONE);
+ remoteViews.setChronometer(ids[3], SystemClock.elapsedRealtime(),
null, false);
}
}
@@ -257,19 +275,17 @@
*
* @param context the context
* @param remoteViews the remote views
- * @param labelId the label id
- * @param valueId the value id
- * @param unitId the unit id
+ * @param ids the item's ids
* @param tripStatistics the trip statistics
* @param metricUnits true to use metric units
*/
- private static void updateTotalDistance(Context context, RemoteViews
remoteViews, int labelId,
- int valueId, int unitId, TripStatistics tripStatistics, boolean
metricUnits) {
+ private static void updateTotalDistance(Context context, RemoteViews
remoteViews, int[] ids,
+ TripStatistics tripStatistics, boolean metricUnits) {
double totalDistance = tripStatistics == null ? Double.NaN :
tripStatistics.getTotalDistance();
String[] totalDistanceParts = StringUtils.getDistanceParts(context,
totalDistance, metricUnits);
- remoteViews.setTextViewText(labelId,
context.getString(R.string.stats_total_distance));
- remoteViews.setTextViewText(valueId, totalDistanceParts[0]);
- remoteViews.setTextViewText(unitId, totalDistanceParts[1]);
+ remoteViews.setTextViewText(ids[0],
context.getString(R.string.stats_total_distance));
+ remoteViews.setTextViewText(ids[1], totalDistanceParts[0]);
+ remoteViews.setTextViewText(ids[2], totalDistanceParts[1]);
}
/**
@@ -277,18 +293,29 @@
*
* @param context the context
* @param remoteViews the remote views
- * @param labelId the label id
- * @param valueId the value id
- * @param unitId the unit id
+ * @param ids the item's ids
* @param tripStatistics the trip statistics
*/
- private static void updateTotalTime(Context context, RemoteViews
remoteViews, int labelId,
- int valueId, int unitId, TripStatistics tripStatistics) {
- String totalTime = tripStatistics == null ?
context.getString(R.string.value_unknown)
- : StringUtils.formatElapsedTime(tripStatistics.getTotalTime());
- remoteViews.setTextViewText(labelId,
context.getString(R.string.stats_total_time));
- remoteViews.setTextViewText(valueId, totalTime);
- remoteViews.setViewVisibility(unitId, View.GONE);
+ private static void updateTotalTime(Context context, RemoteViews
remoteViews, int[] ids,
+ TripStatistics tripStatistics, boolean isRecording, boolean
isPaused) {
+ if (isRecording && !isPaused && tripStatistics != null) {
+ long time = tripStatistics.getTotalTime() +
System.currentTimeMillis()
+ - tripStatistics.getStopTime();
+ remoteViews.setChronometer(ids[3], SystemClock.elapsedRealtime() -
time, null, true);
+ remoteViews.setViewVisibility(ids[1], View.GONE);
+ remoteViews.setViewVisibility(ids[2], View.GONE);
+ remoteViews.setViewVisibility(ids[3], View.VISIBLE);
+ } else {
+ remoteViews.setChronometer(ids[3], SystemClock.elapsedRealtime(),
null, false);
+ remoteViews.setViewVisibility(ids[1], View.VISIBLE);
+ remoteViews.setViewVisibility(ids[2], View.GONE);
+ remoteViews.setViewVisibility(ids[3], View.GONE);
+
+ String totalTime = tripStatistics == null ?
context.getString(R.string.value_unknown)
+ : StringUtils.formatElapsedTime(tripStatistics.getTotalTime());
+ remoteViews.setTextViewText(ids[0],
context.getString(R.string.stats_total_time));
+ remoteViews.setTextViewText(ids[1], totalTime);
+ }
}
/**
@@ -296,24 +323,21 @@
*
* @param context the context
* @param remoteViews the remote views
- * @param labelId the label id
- * @param valueId the value id
- * @param unitId the unit id
+ * @param ids the item's ids
* @param tripStatistics the trip statistics
* @param metricUnits true to use metric units
* @param reportSpeed true to report speed
*/
- private static void updateAverageSpeed(Context context, RemoteViews
remoteViews, int labelId,
- int valueId, int unitId, TripStatistics tripStatistics, boolean
metricUnits,
- boolean reportSpeed) {
+ private static void updateAverageSpeed(Context context, RemoteViews
remoteViews, int[] ids,
+ TripStatistics tripStatistics, boolean metricUnits, boolean
reportSpeed) {
String averageSpeedLabel = context.getString(
reportSpeed ? R.string.stats_average_speed :
R.string.stats_average_pace);
- remoteViews.setTextViewText(labelId, averageSpeedLabel);
+ remoteViews.setTextViewText(ids[0], averageSpeedLabel);
Double speed = tripStatistics == null ? Double.NaN :
tripStatistics.getAverageSpeed();
String[] speedParts = StringUtils.getSpeedParts(context, speed,
metricUnits, reportSpeed);
- remoteViews.setTextViewText(valueId, speedParts[0]);
- remoteViews.setTextViewText(unitId, speedParts[1]);
+ remoteViews.setTextViewText(ids[1], speedParts[0]);
+ remoteViews.setTextViewText(ids[2], speedParts[1]);
}
/**
@@ -321,18 +345,16 @@
*
* @param context the context
* @param remoteViews the remote views
- * @param labelId the label id
- * @param valueId the value id
- * @param unitId the unit id
+ * @param ids the item's ids
* @param tripStatistics the trip statistics
*/
- private static void updateMovingTime(Context context, RemoteViews
remoteViews, int labelId,
- int valueId, int unitId, TripStatistics tripStatistics) {
+ private static void updateMovingTime(
+ Context context, RemoteViews remoteViews, int[] ids, TripStatistics
tripStatistics) {
String movingTime = tripStatistics == null ?
context.getString(R.string.value_unknown)
: StringUtils.formatElapsedTime(tripStatistics.getMovingTime());
- remoteViews.setTextViewText(labelId,
context.getString(R.string.stats_moving_time));
- remoteViews.setTextViewText(valueId, movingTime);
- remoteViews.setViewVisibility(unitId, View.GONE);
+ remoteViews.setTextViewText(ids[0],
context.getString(R.string.stats_moving_time));
+ remoteViews.setTextViewText(ids[1], movingTime);
+ remoteViews.setViewVisibility(ids[2], View.GONE);
}
/**
@@ -340,24 +362,21 @@
*
* @param context the context
* @param remoteViews the remote views
- * @param labelId the label id
- * @param valueId the value id
- * @param unitId the unit id
+ * @param ids the item's ids
* @param tripStatistics the trip statistics
* @param metricUnits true to use metric units
* @param reportSpeed true to report speed
*/
- private static void updateAverageMovingSpeed(Context context,
RemoteViews remoteViews,
- int labelId, int valueId, int unitId, TripStatistics tripStatistics,
boolean metricUnits,
- boolean reportSpeed) {
+ private static void updateAverageMovingSpeed(Context context,
RemoteViews remoteViews, int[] ids,
+ TripStatistics tripStatistics, boolean metricUnits, boolean
reportSpeed) {
String averageMovingSpeedLabel = context.getString(
reportSpeed ? R.string.stats_average_moving_speed :
R.string.stats_average_moving_pace);
- remoteViews.setTextViewText(labelId, averageMovingSpeedLabel);
+ remoteViews.setTextViewText(ids[0], averageMovingSpeedLabel);
Double speed = tripStatistics == null ? Double.NaN :
tripStatistics.getAverageMovingSpeed();
String[] speedParts = StringUtils.getSpeedParts(context, speed,
metricUnits, reportSpeed);
- remoteViews.setTextViewText(valueId, speedParts[0]);
- remoteViews.setTextViewText(unitId, speedParts[1]);
+ remoteViews.setTextViewText(ids[1], speedParts[0]);
+ remoteViews.setTextViewText(ids[2], speedParts[1]);
}
/**
==============================================================================
Revision: a2a777b9be31
Branch: default
Author: Jimmy Shih <
js...@google.com>
Date: Mon Oct 8 18:36:28 2012
Log: fix layout issue in track widget config activity
http://code.google.com/p/mytracks/source/detail?r=a2a777b9be31
Modified:
/MyTracks/res/layout/track_widget_config.xml
/MyTracks/res/values/styles.xml
=======================================
--- /MyTracks/res/layout/track_widget_config.xml Mon Oct 8 17:25:27 2012
+++ /MyTracks/res/layout/track_widget_config.xml Mon Oct 8 18:36:28 2012
@@ -19,32 +19,24 @@
android:layout_width="fill_parent"
android:orientation="vertical" >
<ScrollView style="@style/ScrollView.WithBottomButtons" >
- <TableLayout
+ <LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
- android:padding="8dp"
- android:stretchColumns="0" >
- <TableRow style="@style/TrackWidgetConfigRow" >
- <Spinner
- android:id="@+id/track_widget_config_item1"
- style="@style/TrackWidgetConfigSpinner" />
- </TableRow>
- <TableRow style="@style/TrackWidgetConfigRow" >
- <Spinner
- android:id="@+id/track_widget_config_item2"
- style="@style/TrackWidgetConfigSpinner" />
- </TableRow>
- <TableRow style="@style/TrackWidgetConfigRow" >
- <Spinner
- android:id="@+id/track_widget_config_item3"
- style="@style/TrackWidgetConfigSpinner" />
- </TableRow>
- <TableRow style="@style/TrackWidgetConfigRow" >
- <Spinner
- android:id="@+id/track_widget_config_item4"
- style="@style/TrackWidgetConfigSpinner" />
- </TableRow>
- </TableLayout>
+ android:orientation="vertical"
+ android:padding="8dp" >
+ <Spinner
+ android:id="@+id/track_widget_config_item1"
+ style="@style/TrackWidgetConfigSpinner" />
+ <Spinner
+ android:id="@+id/track_widget_config_item2"
+ style="@style/TrackWidgetConfigSpinner" />
+ <Spinner
+ android:id="@+id/track_widget_config_item3"
+ style="@style/TrackWidgetConfigSpinner" />
+ <Spinner
+ android:id="@+id/track_widget_config_item4"
+ style="@style/TrackWidgetConfigSpinner" />
+ </LinearLayout>
</ScrollView>
<LinearLayout style="@style/BottomButtonBar" >
<include layout="@layout/bottom_buttons" />
=======================================
--- /MyTracks/res/values/styles.xml Mon Oct 8 17:25:27 2012
+++ /MyTracks/res/values/styles.xml Mon Oct 8 18:36:28 2012
@@ -229,15 +229,11 @@
<item name="android:layout_width">63dp</item>
<item name="android:src">@drawable/btn_stop_0</item>
</style>
- <!-- track widget config row -->
- <style name="TrackWidgetConfigRow">
- <item name="android:paddingBottom">20dp</item>
- <item name="android:paddingTop">20dp</item>
- </style>
<!-- track widget config spiner -->
<style name="TrackWidgetConfigSpinner">
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_margin">8dp</item>
<item name="android:layout_width">fill_parent</item>
</style>
<!-- Track widget frame -->