Updated database to save locations as on row entry, rather than 2

closes #86

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-05-28 00:37:17 -04:00
parent 95459c8d57
commit cb66aa6bcd
3 changed files with 14 additions and 8 deletions

View File

@@ -58,14 +58,18 @@ public class RingerDatabase {
/*
* Database keys
*/
public final static String KEY_RADIUS = "radius";
@Deprecated
public final static String KEY_LOCATION_LAT = "location_lat";
@Deprecated
public final static String KEY_LOCATION_LON = "location_lon";
public final static String KEY_RINGER_NAME = "ringer_name";
@Deprecated
public final static String KEY_RINGTONE = "home_ringtone";
@Deprecated
public final static String KEY_NOTIFICATION_RINGTONE = "notification_ringtone";
public final static String KEY_RADIUS = "radius";
public final static String KEY_RINGER_NAME = "ringer_name";
public final static String KEY_LOCATION = "location";
public final static String KEY_RINGTONE_IS_SILENT = "ringtone_is_silent";
public final static String KEY_NOTIFICATION_IS_SILENT = "notification_is_silent";
public final static String KEY_IS_ENABLED = "is_enabled";

View File

@@ -330,14 +330,16 @@ public class RingerProcessingService extends Service {
if(RingerDatabase.parseBoolean(c.getString(1))){
ContentValues info = this.mDb.getRingerInfo(c.getString(0));
if(info.containsKey(RingerDatabase.KEY_LOCATION_LAT) && info.containsKey(RingerDatabase.KEY_LOCATION_LON) && info.containsKey(RingerDatabase.KEY_RADIUS))
if(GeoUtils.isIntersecting(point, new Float(mLocation.getAccuracy()) / 1000, new GeoPoint(info.getAsInteger(RingerDatabase.KEY_LOCATION_LAT), info.getAsInteger(RingerDatabase.KEY_LOCATION_LON)), new Float(info.getAsInteger(RingerDatabase.KEY_RADIUS)) / 1000, Debug.FUDGE_FACTOR)){
if(info.containsKey(RingerDatabase.KEY_LOCATION) && info.containsKey(RingerDatabase.KEY_RADIUS)){
final String[] pointInfo = info.getAsString(RingerDatabase.KEY_LOCATION).split(",");
if(GeoUtils.isIntersecting(point, new Float(mLocation.getAccuracy()) / 1000, new GeoPoint(Integer.parseInt(pointInfo[0]), Integer.parseInt(pointInfo[1])), new Float(info.getAsInteger(RingerDatabase.KEY_RADIUS)) / 1000, Debug.FUDGE_FACTOR)){
c.close();
getRinger(ringer, index);
isDeafult = false;
//break loop, we will only apply the first applicable ringer
break;
}
}
}
index++;
} while (c.moveToNext());

View File

@@ -151,8 +151,7 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
if(this.mListener != null){
ContentValues info = new ContentValues();
info.put(RingerDatabase.KEY_LOCATION_LAT, point.getLatitudeE6());
info.put(RingerDatabase.KEY_LOCATION_LON, point.getLongitudeE6());
info.put(RingerDatabase.KEY_LOCATION, point.toString());
this.mListener.onInfoContentChanged(info);
}
} else if(Debug.DEBUG)
@@ -198,8 +197,9 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
this.mMap.addOverlay(mRadiusOverlay);
this.mRadius.setEnabled(false);
if (this.mInfo.get(RingerDatabase.KEY_LOCATION_LAT) != null && this.mInfo.get(RingerDatabase.KEY_LOCATION_LON) != null){
this.mRadiusOverlay.setLocation(new GeoPoint(this.mInfo.getAsInteger(RingerDatabase.KEY_LOCATION_LAT), this.mInfo.getAsInteger(RingerDatabase.KEY_LOCATION_LON)));
if (this.mInfo.get(RingerDatabase.KEY_LOCATION) != null){
final String[] point = this.mInfo.getAsString(RingerDatabase.KEY_LOCATION).split(",");
this.mRadiusOverlay.setLocation(new GeoPoint(Integer.parseInt(point[0]), Integer.parseInt(point[1])));
}
if (this.mInfo.get(RingerDatabase.KEY_RADIUS) != null){