Merge with 63eb7915dafe329e8f06cc33c56122ee15ea6df7

This commit is contained in:
Bartlomiej Niechwiej
2010-11-17 22:20:15 -08:00
7 changed files with 66 additions and 27 deletions
+13
View File
@@ -103,6 +103,19 @@
<!-- Permissions for misc services --> <!-- Permissions for misc services -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- Features required -->
<uses-feature android:name="android.hardware.location" android:required="true"/>
<uses-feature android:name="android.hardware.location.gps" android:required="true"/>
<uses-feature android:name="android.hardware.touchscreen" android:required="true"/>
<!-- Features optional -->
<uses-feature android:name="android.hardware.bluetooth" android:required="false"/>
<uses-feature android:name="android.hardware.location.network" android:required="false"/>
<uses-feature android:name="android.hardware.sensor.compass" android:required="false"/>
<uses-feature android:name="android.hardware.telephony" android:required="false"/>
<uses-feature android:name="android.hardware.telephony.gsm" android:required="false"/>
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false"/>
<uses-sdk android:minSdkVersion="3"/> <uses-sdk android:minSdkVersion="3"/>
<supports-screens <supports-screens
android:largeScreens="true" android:largeScreens="true"
+2
View File
@@ -9,9 +9,11 @@
<booleanAttribute key="com.android.ide.eclipse.adt.wipedata" value="false"/> <booleanAttribute key="com.android.ide.eclipse.adt.wipedata" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/MyTracks"/> <listEntry value="/MyTracks"/>
<listEntry value="/MyTracks/AndroidManifest.xml"/>
</listAttribute> </listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/> <listEntry value="4"/>
<listEntry value="1"/>
</listAttribute> </listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+2 -2
View File
@@ -26,8 +26,8 @@ limitations under the License.
android:enabled="true" android:enabled="true"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
android:apiKey="0TXoRmxTinrZKQ9JSazj-9A34XX6_lXsRvTpXWA"/> android:apiKey="0y_T_wDlbgovCQMZX7ZClDeveHLLhczEyiUblvw"/>
<!-- corresponding certificate md5: 81:DF:A2:63:53:C7:6B:1E:6C:24:62:D4:91:1C:36:3A --> <!-- corresponding certificate md5: 88:3B:2F:19:EC:0A:9D:E9:33:89:30:BE:94:D1:79:91 -->
<LinearLayout android:id="@+id/messagepane" <LinearLayout android:id="@+id/messagepane"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_width="fill_parent"
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010 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.
-->
<resources>
<array name="left_icons">
<item>@drawable/left_arrow_chart_stateful</item>
<item>@drawable/left_arrow_track_stateful</item>
<item>@drawable/left_arrow_stats_stateful</item>
</array>
<array name="right_icons">
<item>@drawable/right_arrow_stats_stateful</item>
<item>@drawable/right_arrow_chart_stateful</item>
<item>@drawable/right_arrow_track_stateful</item>
</array>
</resources>
@@ -202,17 +202,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
private NavControls navControls; private NavControls navControls;
/** Icons shown on the left for each tab. */
private final int leftIcons[] =
{ R.drawable.left_arrow_chart_stateful,
R.drawable.left_arrow_track_stateful,
R.drawable.left_arrow_stats_stateful };
/** Icons shown on the right for each tab. */
private final int rightIcons[] =
{ R.drawable.right_arrow_stats_stateful,
R.drawable.right_arrow_chart_stateful,
R.drawable.right_arrow_track_stateful };
private final Runnable changeTab = new Runnable() { private final Runnable changeTab = new Runnable() {
public void run() { public void run() {
getTabHost().setCurrentTab(navControls.getCurrentIcons()); getTabHost().setCurrentTab(navControls.getCurrentIcons());
@@ -266,7 +255,6 @@ public class MyTracks extends TabActivity implements OnTouchListener,
providerUtils = MyTracksProviderUtils.Factory.get(this); providerUtils = MyTracksProviderUtils.Factory.get(this);
menuManager = new MenuManager(this); menuManager = new MenuManager(this);
sharedPreferences = getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0); sharedPreferences = getSharedPreferences(MyTracksSettings.SETTINGS_NAME, 0);
dialogManager = new DialogManager(this);
// The volume we want to control is the Text-To-Speech volume // The volume we want to control is the Text-To-Speech volume
int volumeStream = int volumeStream =
@@ -298,7 +286,10 @@ public class MyTracks extends TabActivity implements OnTouchListener,
new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
layout.setLayoutParams(params); layout.setLayoutParams(params);
navControls = navControls =
new NavControls(this, layout, leftIcons, rightIcons, changeTab); new NavControls(this, layout,
getResources().obtainTypedArray(R.array.left_icons),
getResources().obtainTypedArray(R.array.right_icons),
changeTab);
navControls.show(); navControls.show();
tabHost.addView(layout); tabHost.addView(layout);
layout.setOnTouchListener(this); layout.setOnTouchListener(this);
@@ -367,6 +358,7 @@ public class MyTracks extends TabActivity implements OnTouchListener,
// to the user. // to the user.
Log.d(MyTracksConstants.TAG, "MyTracks.onResume"); Log.d(MyTracksConstants.TAG, "MyTracks.onResume");
tryBindTrackRecordingService(); tryBindTrackRecordingService();
dialogManager = new DialogManager(this);
super.onResume(); super.onResume();
} }
@@ -16,6 +16,7 @@
package com.google.android.apps.mytracks; package com.google.android.apps.mytracks;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Handler; import android.os.Handler;
import android.view.MotionEvent; import android.view.MotionEvent;
@@ -62,8 +63,7 @@ public class NavControls {
addView(icon); addView(icon);
} }
public void setIcon(int iconId) { public void setIcon(Drawable drawable) {
Drawable drawable = getContext().getResources().getDrawable(iconId);
icon.setImageDrawable(drawable); icon.setImageDrawable(drawable);
icon.setVisibility(View.VISIBLE); icon.setVisibility(View.VISIBLE);
} }
@@ -102,21 +102,21 @@ public class NavControls {
private final TouchLayout prevImage; private final TouchLayout prevImage;
private final TouchLayout nextImage; private final TouchLayout nextImage;
private final int[] leftIcons; private final TypedArray leftIcons;
private final int[] rightIcons; private final TypedArray rightIcons;
private final Runnable touchRunnable; private final Runnable touchRunnable;
private boolean isVisible = false; private boolean isVisible = false;
private int currentIcons; private int currentIcons;
public NavControls(Context context, ViewGroup container, public NavControls(Context context, ViewGroup container,
int[] leftIcons, int[] rightIcons, TypedArray leftIcons, TypedArray rightIcons,
Runnable touchRunnable) { Runnable touchRunnable) {
this.leftIcons = leftIcons; this.leftIcons = leftIcons;
this.rightIcons = rightIcons; this.rightIcons = rightIcons;
this.touchRunnable = touchRunnable; this.touchRunnable = touchRunnable;
if (leftIcons.length != rightIcons.length || leftIcons.length < 1) { if (leftIcons.length() != rightIcons.length() || leftIcons.length() < 1) {
throw new IllegalArgumentException("Invalid icons specified"); throw new IllegalArgumentException("Invalid icons specified");
} }
if (touchRunnable == null) { if (touchRunnable == null) {
@@ -145,8 +145,8 @@ public class NavControls {
container.addView(prevImage); container.addView(prevImage);
container.addView(nextImage); container.addView(nextImage);
prevImage.setIcon(leftIcons[0]); prevImage.setIcon(leftIcons.getDrawable(0));
nextImage.setIcon(rightIcons[0]); nextImage.setIcon(rightIcons.getDrawable(0));
this.currentIcons = 0; this.currentIcons = 0;
} }
@@ -206,8 +206,9 @@ public class NavControls {
private void shiftIcons(boolean isLeft) { private void shiftIcons(boolean isLeft) {
// Increment or decrement by one, with wrap around // Increment or decrement by one, with wrap around
currentIcons = (currentIcons + leftIcons.length + (isLeft ? -1 : 1)) % leftIcons.length; currentIcons = (currentIcons + leftIcons.length() +
prevImage.setIcon(leftIcons[currentIcons]); (isLeft ? -1 : 1)) % leftIcons.length();
nextImage.setIcon(rightIcons[currentIcons]); prevImage.setIcon(leftIcons.getDrawable(currentIcons));
nextImage.setIcon(rightIcons.getDrawable(currentIcons));
} }
} }
@@ -261,7 +261,9 @@ public class StatusAnnouncerTask implements PeriodicTask {
protected void listenToPhoneState(PhoneStateListener listener, int events) { protected void listenToPhoneState(PhoneStateListener listener, int events) {
TelephonyManager telephony = TelephonyManager telephony =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen(listener, events); if (telephony != null) {
telephony.listen(listener, events);
}
} }
/** /**