forked from upstream-mirrors/OpenTracks
Making My Tracks honeycomb-compatible.
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="gen"/>
|
<classpathentry kind="src" path="gen"/>
|
||||||
<classpathentry exported="true" kind="lib" path="/MyTracksLib/libs/protobuf-java-2.3.0-lite.jar"/>
|
<classpathentry exported="true" kind="lib" path="/MyTracksLib/libs/protobuf-java-2.3.0-lite.jar"/>
|
||||||
<classpathentry kind="src" path="MyTracksLib_src"/>
|
|
||||||
<classpathentry kind="lib" path="libs/libmymaps.jar"/>
|
<classpathentry kind="lib" path="libs/libmymaps.jar"/>
|
||||||
|
<classpathentry kind="src" path="MyTracksLib_src"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -164,14 +164,15 @@ limitations under the License.
|
|||||||
<!-- Features required -->
|
<!-- Features required -->
|
||||||
<uses-feature android:name="android.hardware.location" android:required="true"/>
|
<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.location.gps" android:required="true"/>
|
||||||
<uses-feature android:name="android.hardware.touchscreen" android:required="true"/>
|
|
||||||
|
|
||||||
<!-- Features optional -->
|
<!-- Features optional -->
|
||||||
<uses-feature android:name="android.hardware.bluetooth" android:required="false"/>
|
<uses-feature android:name="android.hardware.bluetooth" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.hardware.faketouch" android:required="false"/>
|
||||||
<uses-feature android:name="android.hardware.location.network" 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.sensor.compass" android:required="false"/>
|
||||||
<uses-feature android:name="android.hardware.telephony" 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.telephony.gsm" android:required="false"/>
|
||||||
|
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||||
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false"/>
|
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false"/>
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="3"/>
|
<uses-sdk android:minSdkVersion="3"/>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
# Indicates whether an apk should be generated for each density.
|
# Indicates whether an apk should be generated for each density.
|
||||||
split.density=false
|
split.density=false
|
||||||
# Project target.
|
# Project target.
|
||||||
target=Google Inc.:Google APIs:9
|
target=Google Inc.:Google APIs:11
|
||||||
android.library.reference.1=../MyTracksLib/
|
android.library.reference.1=../MyTracksLib/
|
||||||
|
|
||||||
# ProGuard is turned off while we investigate the removal of code that
|
# ProGuard is turned off while we investigate the removal of code that
|
||||||
|
|||||||
@@ -15,11 +15,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.util;
|
package com.google.android.apps.mytracks.util;
|
||||||
|
|
||||||
|
import static com.google.android.apps.mytracks.MyTracksConstants.TAG;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Cupcake (API level 3) specific implementation of the
|
* The Cupcake (API level 3) specific implementation of the
|
||||||
@@ -33,19 +38,38 @@ public class CupcakePlatformAdapter implements ApiPlatformAdapter {
|
|||||||
public void startForeground(Service service,
|
public void startForeground(Service service,
|
||||||
NotificationManager notificationManager, int id,
|
NotificationManager notificationManager, int id,
|
||||||
Notification notification) {
|
Notification notification) {
|
||||||
service.setForeground(true);
|
setServiceForeground(service, true);
|
||||||
|
|
||||||
notificationManager.notify(id, notification);
|
notificationManager.notify(id, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopForeground(Service service,
|
public void stopForeground(Service service,
|
||||||
NotificationManager notificationManager, int id) {
|
NotificationManager notificationManager, int id) {
|
||||||
service.setForeground(false);
|
setServiceForeground(service, false);
|
||||||
if (id != -1) {
|
if (id != -1) {
|
||||||
notificationManager.cancel(id);
|
notificationManager.cancel(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setServiceForeground(Service service, boolean foreground) {
|
||||||
|
// setForeground has been completely removed in API level 11, so we use reflection.
|
||||||
|
try {
|
||||||
|
Method setForegroundMethod = Service.class.getMethod("setForeground", boolean.class);
|
||||||
|
setForegroundMethod.invoke(service, foreground);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.e(TAG, "Unable to set service foreground state", e);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
Log.e(TAG, "Unable to set service foreground state", e);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.e(TAG, "Unable to set service foreground state", e);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
Log.e(TAG, "Unable to set service foreground state", e);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
Log.e(TAG, "Unable to set service foreground state", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stopHandlerThread(HandlerThread handlerThread) {
|
public boolean stopHandlerThread(HandlerThread handlerThread) {
|
||||||
// Do nothing, as Cupcake doesn't provide quit().
|
// Do nothing, as Cupcake doesn't provide quit().
|
||||||
|
|||||||
@@ -8,5 +8,5 @@
|
|||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-9
|
target=android-11
|
||||||
android.library=true
|
android.library=true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<factorypath>
|
<factorypath>
|
||||||
<factorypathentry kind="WKSPJAR" id="/MyTracksTest/libs/AndroidMockGenerator.jar" enabled="true" runInBatchMode="false"/>
|
<factorypathentry kind="WKSPJAR" id="/MyTracksTest/libs/AndroidMockGenerator.jar" enabled="true" runInBatchMode="false"/>
|
||||||
<factorypathentry kind="VARJAR" id="ANDROID_SDK/platforms/android-9/android.jar" enabled="true" runInBatchMode="false"/>
|
<factorypathentry kind="VARJAR" id="ANDROID_SDK/platforms/android-11/android.jar" enabled="true" runInBatchMode="false"/>
|
||||||
<factorypathentry kind="VARJAR" id="ANDROID_SDK/add-ons/addon_google_apis_google_inc_9/libs/maps.jar" enabled="true" runInBatchMode="false"/>
|
<factorypathentry kind="VARJAR" id="ANDROID_SDK/add-ons/addon_google_apis_google_inc_11/libs/maps.jar" enabled="true" runInBatchMode="false"/>
|
||||||
<factorypathentry kind="VARJAR" id="MYTRACKS_BIN" enabled="true" runInBatchMode="false"/>
|
<factorypathentry kind="VARJAR" id="MYTRACKS_BIN" enabled="true" runInBatchMode="false"/>
|
||||||
</factorypath>
|
</factorypath>
|
||||||
|
|||||||
@@ -10,4 +10,4 @@
|
|||||||
# Indicates whether an apk should be generated for each density.
|
# Indicates whether an apk should be generated for each density.
|
||||||
split.density=false
|
split.density=false
|
||||||
# Project target.
|
# Project target.
|
||||||
target=Google Inc.:Google APIs:9
|
target=Google Inc.:Google APIs:11
|
||||||
|
|||||||
+11
@@ -20,6 +20,7 @@ import android.content.SharedPreferences.Editor;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
@@ -81,6 +82,11 @@ public class PreferenceBackupHelperTest extends TestCase {
|
|||||||
return put(key, value);
|
return put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Editor putStringSet(String key, Set<String> value) {
|
||||||
|
return put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
private <T> Editor put(String key, T value) {
|
private <T> Editor put(String key, T value) {
|
||||||
newPreferences.put(key, value);
|
newPreferences.put(key, value);
|
||||||
return this;
|
return this;
|
||||||
@@ -137,6 +143,11 @@ public class PreferenceBackupHelperTest extends TestCase {
|
|||||||
return get(key, defValue);
|
return get(key, defValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getStringSet(String key, Set<String> defValue) {
|
||||||
|
return get(key, defValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerOnSharedPreferenceChangeListener(
|
public void registerOnSharedPreferenceChangeListener(
|
||||||
OnSharedPreferenceChangeListener listener) {
|
OnSharedPreferenceChangeListener listener) {
|
||||||
|
|||||||
@@ -8,6 +8,6 @@
|
|||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=Google Inc.:Google APIs:9
|
target=Google Inc.:Google APIs:11
|
||||||
proguard.config=proguard.cfg
|
proguard.config=proguard.cfg
|
||||||
android.library.reference.1=../MyTracksLib/
|
android.library.reference.1=../MyTracksLib/
|
||||||
|
|||||||
@@ -8,4 +8,4 @@
|
|||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=Google Inc.:Google APIs:9
|
target=Google Inc.:Google APIs:11
|
||||||
|
|||||||
Reference in New Issue
Block a user