From c708c3dc009561b064251f4b932d20352586e6b6 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 21 Jul 2012 22:44:35 -0400 Subject: [PATCH] Started removing skyhook location services from the project --- LocationRinger/AndroidManifest.xml | 4 +- .../services/LocationService.java | 30 ++++----- .../LocationRinger/ui/ListActivity.java | 61 +++++++++---------- 3 files changed, 48 insertions(+), 47 deletions(-) diff --git a/LocationRinger/AndroidManifest.xml b/LocationRinger/AndroidManifest.xml index c21d3d6..74ebf72 100644 --- a/LocationRinger/AndroidManifest.xml +++ b/LocationRinger/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="64" + android:versionName="ec647d5" > diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/services/LocationService.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/services/LocationService.java index e69b2a1..2da69b7 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/services/LocationService.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/services/LocationService.java @@ -6,19 +6,18 @@ */ package com.TwentyCodes.android.LocationRinger.services; -import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import anroid.v4.compat.NotificationCompat; import com.TwentyCodes.android.LocationRinger.R; import com.TwentyCodes.android.LocationRinger.debug.Debug; import com.TwentyCodes.android.LocationRinger.ui.ListActivity; import com.TwentyCodes.android.LocationRinger.ui.SettingsActivity; -import com.TwentyCodes.android.SkyHook.SkyHookService; import com.TwentyCodes.android.debug.LocationLibraryConstants; import com.TwentyCodes.android.exception.ExceptionHandler; @@ -26,7 +25,7 @@ import com.TwentyCodes.android.exception.ExceptionHandler; * We override the location service so we can attach the exception handler * @author ricky barrette */ -public class LocationService extends SkyHookService { +public class LocationService extends com.TwentyCodes.android.location.LocationService { private final int GATHERING_LOCATION_ONGING_NOTIFICATION_ID = 232903877; private SharedPreferences mSettings; @@ -40,8 +39,8 @@ public class LocationService extends SkyHookService { */ public static Intent getSingleShotServiceIntent(Context context) { return new Intent(context, LocationService.class) - .putExtra(LocationLibraryConstants.INTENT_EXTRA_REQUIRED_ACCURACY, Debug.ACCURACY) - .setAction(LocationLibraryConstants.INTENT_ACTION_UPDATE); + .putExtra(LocationLibraryConstants.INTENT_EXTRA_REQUIRED_ACCURACY, Debug.ACCURACY) + .setAction(LocationLibraryConstants.INTENT_ACTION_UPDATE); } /* (non-Javadoc) @@ -85,10 +84,7 @@ public class LocationService extends SkyHookService { * @author ricky barrette */ public static ComponentName startMultiShotService(final Context context){ - Intent i = new Intent(context, LocationService.class) - .putExtra(LocationLibraryConstants.INTENT_EXTRA_PERIOD_BETWEEN_UPDATES, Debug.UPDATE_INTERVAL) - .putExtra(LocationLibraryConstants.INTENT_EXTRA_REQUIRED_ACCURACY, Debug.ACCURACY) - .setAction(LocationLibraryConstants.INTENT_ACTION_UPDATE); + Intent i = getSingleShotServiceIntent(context).putExtra(LocationLibraryConstants.INTENT_EXTRA_PERIOD_BETWEEN_UPDATES, Debug.UPDATE_INTERVAL); return context.startService(i); } @@ -98,11 +94,17 @@ public class LocationService extends SkyHookService { */ private void startOnGoingNotification() { this.mNotificationManager = (NotificationManager) this.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); - Notification notifyDetails = new Notification(R.drawable.icon, this.getString(R.string.app_name), System.currentTimeMillis()); - PendingIntent intent = PendingIntent.getActivity(this, 0, new Intent(this, ListActivity.class), android.content.Intent.FLAG_ACTIVITY_NEW_TASK); - notifyDetails.setLatestEventInfo(this, this.getString(R.string.app_name), this.getString(R.string.gathering), intent); - notifyDetails.flags |= Notification.FLAG_ONGOING_EVENT; - this.mNotificationManager.notify(this.GATHERING_LOCATION_ONGING_NOTIFICATION_ID, notifyDetails); + + final NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext()) + .setContentTitle(getString(R.string.app_name)) + .setContentText(this.getString(R.string.gathering)) + .setTicker(this.getString(R.string.gathering)) + .setSmallIcon(R.drawable.icon) + .setContentIntent(PendingIntent.getActivity(this, 0, new Intent(this, ListActivity.class), android.content.Intent.FLAG_ACTIVITY_NEW_TASK)) + .setWhen(System.currentTimeMillis()) + .setOngoing(true); + + this.mNotificationManager.notify(this.GATHERING_LOCATION_ONGING_NOTIFICATION_ID, builder.getNotification()); } /** diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/ListActivity.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/ListActivity.java index 239a48c..0107bc5 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/ListActivity.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/ListActivity.java @@ -16,7 +16,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.os.Bundle; -import android.os.Handler; import android.os.Looper; import android.os.Parcelable; import android.view.ContextMenu; @@ -188,8 +187,8 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli new SkyHookRegistration(this).registerNewUser(this); } - if(!this.getIntent().hasExtra(NO_SPLASH)) - showSplashScreen(); +// if(!this.getIntent().hasExtra(NO_SPLASH)) +// showSplashScreen(); if(action != null) if(action.equals(ACTION_NEW_RINGER)) @@ -409,32 +408,32 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli setResult(RESULT_OK, intent); } - /** - * Shows the splash screen over the full Activity - */ - protected void showSplashScreen() { -// mMap.setGPSDialogEnabled(false); - mSplashDialog = new Dialog(this, android.R.style.Theme_Translucent); - mSplashDialog.setContentView(R.layout.powered_by_skyhook); - mSplashDialog.setCancelable(false); - mSplashDialog.show(); - - // Set Runnable to remove splash screen just in case - final Handler handler = new Handler(); - handler.postDelayed(new Runnable() { - @Override - public void run() { - removeSplashScreen(); - - /* - * uncomment the following to display the eula - */ -// //loads first boot dialog if this is the first boot -// if (! mSettings.getBoolean(Settings.ACCEPTED, false) || Debug.FORCE_FIRSTBOOT_DIALOG) -// eulaAlert(); -// else -// update(); - } - }, 2000); - } +// /** +// * Shows the splash screen over the full Activity +// */ +// protected void showSplashScreen() { +//// mMap.setGPSDialogEnabled(false); +// mSplashDialog = new Dialog(this, android.R.style.Theme_Translucent); +// mSplashDialog.setContentView(R.layout.powered_by_skyhook); +// mSplashDialog.setCancelable(false); +// mSplashDialog.show(); +// +// // Set Runnable to remove splash screen just in case +// final Handler handler = new Handler(); +// handler.postDelayed(new Runnable() { +// @Override +// public void run() { +// removeSplashScreen(); +// +// /* +// * uncomment the following to display the eula +// */ +//// //loads first boot dialog if this is the first boot +//// if (! mSettings.getBoolean(Settings.ACCEPTED, false) || Debug.FORCE_FIRSTBOOT_DIALOG) +//// eulaAlert(); +//// else +//// update(); +// } +// }, 2000); +// } } \ No newline at end of file