seperated how and what into diffrent activitys
This commit is contained in:
@@ -8,14 +8,14 @@ package com.TwentyCodes.android.LocationRinger;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.TwentyCodes.android.LocationRinger.ui.RingerListActivity;
|
||||
import com.TwentyCodes.android.LocationRinger.ui.ListActivity;
|
||||
import com.TwentyCodes.android.exception.ExceptionHandler;
|
||||
|
||||
/**
|
||||
* This is the main Activity for Location Ringer
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class LocationRinger extends RingerListActivity {
|
||||
public class LocationRinger extends ListActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@@ -47,7 +47,7 @@ public class RingerDatabase {
|
||||
/*
|
||||
* database information values
|
||||
*/
|
||||
private final int DATABASE_VERSION = 3;
|
||||
private final int DATABASE_VERSION = 4;
|
||||
|
||||
/*
|
||||
* the following is for the table that holds the other table names
|
||||
@@ -58,15 +58,15 @@ public class RingerDatabase {
|
||||
/*
|
||||
* Database keys
|
||||
*/
|
||||
public final static String KEY_RADIUS = "radius";
|
||||
public final static String KEY_LOCATION_LAT = "location_lat";
|
||||
public final static String KEY_LOCATION_LON = "location_lon";
|
||||
public final static String KEY_RINGER_NAME = "ringer_name";
|
||||
public final static String KEY_RINGTONE = "home_ringtone";
|
||||
public final static String KEY_NOTIFICATION_RINGTONE = "notification_ringtone";
|
||||
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";
|
||||
public final static String KEY_RADIUS = "radius";
|
||||
public final static String KEY_LOCATION_LAT = "location_lat";
|
||||
public final static String KEY_LOCATION_LON = "location_lon";
|
||||
public final static String KEY_RINGTONE_URI = "ringtone_uri";
|
||||
public final static String KEY_NOTIFICATION_RINGTONE_URI = "away_notification_uri";
|
||||
public final static String KEY_RINGTONE_VOLUME = "ringtone_volume";
|
||||
@@ -165,10 +165,7 @@ private class OpenHelper extends SQLiteOpenHelper {
|
||||
db.execSQL("CREATE TABLE " + RINGER_TABLE +
|
||||
"(id INTEGER PRIMARY KEY, " +
|
||||
KEY_RINGER_NAME+" TEXT, " +
|
||||
KEY_IS_ENABLED+" TEXT, " +
|
||||
KEY_RADIUS+" INTEGER, " +
|
||||
KEY_LOCATION_LAT+" INTEGER, " +
|
||||
KEY_LOCATION_LON+" INTEGER)");
|
||||
KEY_IS_ENABLED+" TEXT)");
|
||||
db.execSQL("CREATE TABLE " + RINGER_INFO_TABLE +
|
||||
"(id INTEGER PRIMARY KEY, " +
|
||||
KEY_RINGER_NAME+" TEXT, " +
|
||||
@@ -232,6 +229,31 @@ private class OpenHelper extends SQLiteOpenHelper {
|
||||
convert2to3(db);
|
||||
//remove old tables
|
||||
db.execSQL("DROP TABLE IF EXISTS two");
|
||||
case 3:
|
||||
Cursor c = db.query(RINGER_TABLE, new String[] { "id", KEY_RINGER_NAME, KEY_LOCATION_LAT, KEY_LOCATION_LON, KEY_RADIUS }, null, null, null, null, null);;
|
||||
c.moveToFirst();
|
||||
if (c.moveToFirst()) {
|
||||
do {
|
||||
if(Debug.DEBUG)
|
||||
Log.d(TAG, "Moving: "+c.getInt(0)+" "+c.getString(1)+" "+c.getInt(2)+", "+c.getInt(3)+" @ "+ c.getInt(4) +"m");
|
||||
ContentValues ringer = new ContentValues();
|
||||
ContentValues info = new ContentValues();
|
||||
ringer.put(KEY_RINGER_NAME, c.getString(1));
|
||||
info.put(KEY_LOCATION_LAT, c.getInt(2));
|
||||
info.put(KEY_LOCATION_LON, c.getInt(3));
|
||||
info.put(KEY_RADIUS, c.getInt(4));
|
||||
updateRinger(c.getInt(0), ringer, info);
|
||||
} while (c.moveToNext());
|
||||
}
|
||||
//drop old location trigger information
|
||||
db.execSQL("CREATE TABLE ringers_new (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
KEY_RINGER_NAME+" TEXT, " +
|
||||
KEY_IS_ENABLED+" TEXT)");
|
||||
db.execSQL("INSERT INTO ringers_new SELECT id, "+ KEY_RINGER_NAME +", "+ KEY_IS_ENABLED +" FROM "+RINGER_TABLE);
|
||||
db.execSQL("DROP TABLE "+ RINGER_TABLE);
|
||||
db.execSQL("ALTER TABLE ringers_new RENAME TO "+ RINGER_TABLE);
|
||||
|
||||
}
|
||||
handler.sendEmptyMessage(0);
|
||||
RingerDatabase.this.isUpgrading = false;
|
||||
@@ -380,7 +402,7 @@ private class OpenHelper extends SQLiteOpenHelper {
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public Cursor getAllRingers(){
|
||||
return this.mDb.query(RINGER_TABLE, new String[] { KEY_RINGER_NAME, KEY_IS_ENABLED, KEY_RADIUS, KEY_LOCATION_LAT, KEY_LOCATION_LON }, null, null, null, null, null);
|
||||
return this.mDb.query(RINGER_TABLE, new String[] { KEY_RINGER_NAME, KEY_IS_ENABLED }, null, null, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,7 +431,7 @@ private class OpenHelper extends SQLiteOpenHelper {
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public Cursor getRingerFromId(long id) {
|
||||
return this.mDb.query(RINGER_TABLE, new String[]{ KEY_RINGER_NAME, KEY_IS_ENABLED, KEY_RADIUS, KEY_LOCATION_LAT, KEY_LOCATION_LON }, "id = "+id, null, null, null, null);
|
||||
return this.mDb.query(RINGER_TABLE, new String[]{ KEY_RINGER_NAME, KEY_IS_ENABLED }, "id = "+id, null, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -418,9 +440,18 @@ private class OpenHelper extends SQLiteOpenHelper {
|
||||
* @return
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public Cursor getRingerInfo(String ringerName){
|
||||
return this.mDb.query(RINGER_INFO_TABLE,
|
||||
new String[]{ KEY, KEY_VALUE }, KEY_RINGER_NAME +" = "+ DatabaseUtils.sqlEscapeString(ringerName), null, null, null, null);
|
||||
public ContentValues getRingerInfo(String ringerName){
|
||||
ContentValues values = new ContentValues();
|
||||
Cursor info = this.mDb.query(RINGER_INFO_TABLE, new String[]{ KEY, KEY_VALUE }, KEY_RINGER_NAME +" = "+ DatabaseUtils.sqlEscapeString(ringerName), null, null, null, null);
|
||||
if (info.moveToFirst()) {
|
||||
do {
|
||||
values.put(info.getString(0), info.getString(1));
|
||||
} while (info.moveToNext());
|
||||
}
|
||||
if (info != null && !info.isClosed()) {
|
||||
info.close();
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -540,7 +571,11 @@ private class OpenHelper extends SQLiteOpenHelper {
|
||||
* @param info values
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void updateRinger(long id, ContentValues ringer, ContentValues info){
|
||||
public void updateRinger(long id, ContentValues ringer, ContentValues info) throws NullPointerException{
|
||||
|
||||
if(ringer == null || info == null)
|
||||
throw new NullPointerException("ringer content was null");
|
||||
|
||||
String ringer_name = getRingerName(id);
|
||||
|
||||
if(!ringer_name.equals(ringer.getAsString(RingerDatabase.KEY_RINGER_NAME)))
|
||||
|
||||
@@ -326,16 +326,19 @@ public class RingerProcessingService extends Service {
|
||||
if (c.moveToFirst()) {
|
||||
do {
|
||||
if(Debug.DEBUG)
|
||||
Log.d(TAG, "Checking ringer "+c.getString(0)+" "+c.getInt(3)+", "+c.getInt(4)+" @ "+ c.getInt(2) +"m");
|
||||
Log.d(TAG, "Checking ringer "+c.getString(0));
|
||||
|
||||
if(RingerDatabase.parseBoolean(c.getString(1)))
|
||||
if(GeoUtils.isIntersecting(point, new Float(mLocation.getAccuracy()) / 1000, new GeoPoint(c.getInt(3), c.getInt(4)), new Float(c.getInt(2)) / 1000, Debug.FUDGE_FACTOR)){
|
||||
c.close();
|
||||
getRinger(ringer, index);
|
||||
isDeafult = false;
|
||||
//break loop, we will only apply the first applicable ringer
|
||||
break;
|
||||
}
|
||||
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)){
|
||||
c.close();
|
||||
getRinger(ringer, index);
|
||||
isDeafult = false;
|
||||
//break loop, we will only apply the first applicable ringer
|
||||
break;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
} while (c.moveToNext());
|
||||
}
|
||||
@@ -363,22 +366,13 @@ public class RingerProcessingService extends Service {
|
||||
* @return
|
||||
*/
|
||||
private ContentValues getRinger(ContentValues values, long id) {
|
||||
|
||||
String name = this.mDb.getRingerName(id);
|
||||
values.put(RingerDatabase.KEY_RINGER_NAME, name);
|
||||
|
||||
/*
|
||||
* get the ringer's info, and parse it into content values
|
||||
*/
|
||||
Cursor c = this.mDb.getRingerInfo(name);
|
||||
if (c.moveToFirst()) {
|
||||
do {
|
||||
values.put(c.getString(0), c.getString(1));
|
||||
} while (c.moveToNext());
|
||||
}
|
||||
if (c != null && !c.isClosed()) {
|
||||
c.close();
|
||||
}
|
||||
values.putAll(this.mDb.getRingerInfo(name));
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,369 @@
|
||||
/**
|
||||
* RingerInformationHowActivity.java
|
||||
* @date Jul 29, 2011
|
||||
* @author Twenty Codes, LLC
|
||||
* @author ricky barrette
|
||||
*/
|
||||
package com.TwentyCodes.android.LocationRinger.ui;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.TwentyCodes.android.LocationRinger.LocationSelectedListener;
|
||||
import com.TwentyCodes.android.LocationRinger.R;
|
||||
import com.TwentyCodes.android.LocationRinger.db.RingerDatabase;
|
||||
import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
||||
import com.TwentyCodes.android.SkyHook.SkyHook;
|
||||
import com.TwentyCodes.android.location.GeoPointLocationListener;
|
||||
import com.TwentyCodes.android.location.MapView;
|
||||
import com.google.android.maps.GeoPoint;
|
||||
|
||||
/**
|
||||
* This activity will allow users to pick how a ringer works. Using this activity they will pick triggers for this ringer
|
||||
* @author ricky
|
||||
*/
|
||||
public class HowActivity extends com.google.android.maps.MapActivity implements LocationSelectedListener, GeoPointLocationListener, OnClickListener, OnCheckedChangeListener, OnSeekBarChangeListener {
|
||||
|
||||
private static final String TAG = "RingerInformationHowActivity";
|
||||
private static final int ADD_ID = 1;
|
||||
private static final int WHAT_REQUEST_CODE = 467468436;
|
||||
private SeekBar mRadius;
|
||||
private MapView mMapView;
|
||||
private ToggleButton mMapEditToggle;
|
||||
private RadiusOverlay mRadiusOverlay;
|
||||
private GeoPoint mPoint;
|
||||
private SkyHook mSkyHook;
|
||||
private ProgressDialog mGpsProgress;
|
||||
private boolean isFirstFix;
|
||||
private ScrollView mScrollView;
|
||||
|
||||
@Override
|
||||
protected boolean isRouteDisplayed() {
|
||||
//UNUSED
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the HOW activity finishes, this will just pass the results back to the ringer list activity
|
||||
*/
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if(resultCode == RESULT_OK){
|
||||
this.setResult(RESULT_OK, data);
|
||||
this.finish();
|
||||
}
|
||||
//don show for default
|
||||
if(this.getIntent().getBooleanExtra(ListActivity.KEY_IS_DEFAULT, false))
|
||||
this.finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a toggle button's state is changed
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
switch(buttonView.getId()){
|
||||
|
||||
case R.id.map_edit_toggle:
|
||||
this.isFirstFix = isChecked;
|
||||
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
|
||||
isChecked
|
||||
? (this.getResources().getDisplayMetrics().heightPixels - findViewById(R.id.map_controls).getHeight())
|
||||
: (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 350, getResources().getDisplayMetrics())));
|
||||
if(isChecked){
|
||||
this.mSkyHook.getUpdates();
|
||||
params.addRule(RelativeLayout.ALIGN_PARENT_TOP );
|
||||
this.mGpsProgress = ProgressDialog.show(this, "", this.getText(R.string.gps_fix), true, true);
|
||||
} else {
|
||||
this.mSkyHook.removeUpdates();
|
||||
params.addRule(RelativeLayout.BELOW, R.id.info);
|
||||
params.addRule(RelativeLayout.ALIGN_BOTTOM );
|
||||
if(this.mGpsProgress != null)
|
||||
this.mGpsProgress.dismiss();
|
||||
}
|
||||
findViewById(R.id.map_info).setLayoutParams(params );
|
||||
|
||||
this.mMapView.setDoubleTapZoonEnabled(isChecked);
|
||||
//buttons
|
||||
findViewById(R.id.mark_my_location).setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
findViewById(R.id.my_location).setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
findViewById(R.id.map_mode).setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
findViewById(R.id.search).setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
findViewById(R.id.add_feature_button).setVisibility(isChecked ? View.GONE : View.VISIBLE);
|
||||
this.mScrollView.invalidate();
|
||||
this.mScrollView.setScrollEnabled(! isChecked);
|
||||
this.mMapView.setBuiltInZoomControls(isChecked);
|
||||
this.mMapView.setClickable(isChecked);
|
||||
this.mRadius.setEnabled(isChecked);
|
||||
Toast.makeText(this, isChecked ? getString(R.string.map_editing_enabled) : getString(R.string.map_editiing_disabled), Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a view is clicked
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()){
|
||||
case R.id.mark_my_location:
|
||||
if(this.mPoint != null){
|
||||
this.mRadiusOverlay.setLocation(mPoint);
|
||||
this.mMapView.getController().setCenter(mPoint);
|
||||
}
|
||||
break;
|
||||
case R.id.my_location:
|
||||
if(this.mPoint != null)
|
||||
this.mMapView.getController().setCenter(mPoint);
|
||||
break;
|
||||
case R.id.map_mode:
|
||||
this.mMapView.setSatellite(mMapView.isSatellite() ? false : true);
|
||||
break;
|
||||
case R.id.search:
|
||||
new SearchDialog(this, this).show();
|
||||
break;
|
||||
case R.id.add_feature_button:
|
||||
Toast.makeText(this, "NO TRIGGERS YET", Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case R.id.save_ringer_button:
|
||||
save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the acivity is first created
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
this.setContentView(R.layout.how);
|
||||
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
|
||||
this.mSkyHook = new SkyHook(this);
|
||||
this.mSkyHook.setLocationListener(this);
|
||||
|
||||
this.mScrollView = (ScrollView) findViewById(R.id.scrollview);
|
||||
|
||||
this.mMapView = (MapView) findViewById(R.id.mapview);
|
||||
this.mRadius = (SeekBar) findViewById(R.id.radius);
|
||||
this.mRadius.setMax(Debug.MAX_RADIUS_IN_METERS);
|
||||
this.mMapView.setClickable(false);
|
||||
this.mMapEditToggle = (ToggleButton) findViewById(R.id.map_edit_toggle);
|
||||
this.mMapEditToggle.setChecked(false);
|
||||
this.mMapEditToggle.setOnCheckedChangeListener(this);
|
||||
this.mRadiusOverlay = new RadiusOverlay();
|
||||
this.mRadius.setOnSeekBarChangeListener(this);
|
||||
this.mMapView.getOverlays().add(mRadiusOverlay);
|
||||
this.mRadius.setEnabled(false);
|
||||
|
||||
findViewById(R.id.mark_my_location).setOnClickListener(this);
|
||||
findViewById(R.id.my_location).setOnClickListener(this);
|
||||
findViewById(R.id.map_mode).setOnClickListener(this);
|
||||
findViewById(R.id.search).setOnClickListener(this);
|
||||
findViewById(R.id.save_ringer_button).setOnClickListener(this);
|
||||
findViewById(R.id.add_feature_button).setOnClickListener(this);
|
||||
|
||||
|
||||
Intent data = this.getIntent();
|
||||
|
||||
this.setTitle(getString(R.string.editing)+" "+data.getStringExtra(RingerDatabase.KEY_RINGER_NAME));
|
||||
|
||||
if(data.hasExtra(ListActivity.KEY_INFO)){
|
||||
/*
|
||||
* We need to null check all the values
|
||||
*/
|
||||
ContentValues info = (ContentValues) data.getParcelableExtra(ListActivity.KEY_INFO);
|
||||
|
||||
if (info.get(RingerDatabase.KEY_LOCATION_LAT) != null && info.get(RingerDatabase.KEY_LOCATION_LON) != null){
|
||||
this.mRadiusOverlay.setLocation(new GeoPoint(info.getAsInteger(RingerDatabase.KEY_LOCATION_LAT), info.getAsInteger(RingerDatabase.KEY_LOCATION_LON)));
|
||||
}
|
||||
|
||||
if (info.get(RingerDatabase.KEY_RADIUS) != null){
|
||||
this.mRadius.setProgress(info.getAsInteger(RingerDatabase.KEY_RADIUS));
|
||||
}
|
||||
|
||||
if(data.getBooleanExtra(ListActivity.KEY_IS_DEFAULT, false)){
|
||||
this.startActivityForResult(new Intent(this, WhatActivity.class).putExtras(this.getIntent()), WHAT_REQUEST_CODE);
|
||||
}
|
||||
} else
|
||||
this.setTitle(R.string.new_ringer);
|
||||
|
||||
if(this.mRadiusOverlay.getLocation() != null){
|
||||
this.mMapView.getController().setCenter(this.mRadiusOverlay.getLocation());
|
||||
this.mMapView.getController().setZoom(16);
|
||||
}
|
||||
|
||||
|
||||
this.mMapView.setDoubleTapZoonEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the main menu that is displayed when the menu button is clicked
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(0, ADD_ID, 0, getString(R.string.add_feature)).setIcon(android.R.drawable.ic_menu_add);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.android.maps.MapActivity#onDestroy()
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
this.mSkyHook.removeUpdates();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when skyhook has a location to report
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public void onLocationChanged(GeoPoint point, int accuracy) {
|
||||
this.mPoint = point;
|
||||
|
||||
if(point != null){
|
||||
|
||||
/*
|
||||
* if this is the first fix and the radius overlay does not have a point specified
|
||||
* then pan the map, and zoom in to the users current location
|
||||
*/
|
||||
if(this.isFirstFix)
|
||||
if(this.mRadiusOverlay.getLocation() == null){
|
||||
if(this.mMapView != null){
|
||||
this.mMapView.getController().setCenter(point);
|
||||
this.mMapView.getController().setZoom((this.mMapView.getMaxZoomLevel() - 5));
|
||||
}
|
||||
this.isFirstFix = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* dismiss the acquiring gps dialog
|
||||
*/
|
||||
if(this.mGpsProgress != null)
|
||||
this.mGpsProgress.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
@Override
|
||||
public void onLocationSelected(GeoPoint point) {
|
||||
if(point != null){
|
||||
if(Debug.DEBUG)
|
||||
Log.d(TAG, "onLocationSelected() "+ point.toString());
|
||||
|
||||
if(this.mRadiusOverlay != null)
|
||||
this.mRadiusOverlay.setLocation(point);
|
||||
|
||||
if(this.mMapView != null){
|
||||
this.mMapView.getController().setCenter(point);
|
||||
this.mMapView.getController().setZoom((this.mMapView.getMaxZoomLevel() - 5));
|
||||
}
|
||||
} else if(Debug.DEBUG)
|
||||
Log.d(TAG, "onLocationSelected() Location was null");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch(item.getItemId()){
|
||||
case ADD_ID:
|
||||
//TODO display triggers
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a seekbar is has its progress changed
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
switch (seekBar.getId()){
|
||||
case R.id.radius:
|
||||
this.mRadiusOverlay.setRadius(progress);
|
||||
this.mMapView.invalidate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
//UNUSED
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
//UNUSED
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a bundle containing all the information that needs to be saved, and returns it to the starting activity
|
||||
* @author ricky barrette
|
||||
*/
|
||||
private void save() {
|
||||
final ProgressDialog progress = ProgressDialog.show(this, "", this.getText(R.string.saving), true, true);
|
||||
|
||||
//Generate the intent in a thread to prevent anr's and allow for progress dialog
|
||||
new Thread( new Runnable(){
|
||||
@Override
|
||||
public void run(){
|
||||
Looper.prepare();
|
||||
|
||||
Intent data = new Intent(HowActivity.this, WhatActivity.class).putExtras(HowActivity.this.getIntent());
|
||||
GeoPoint point = HowActivity.this.mRadiusOverlay.getLocation();
|
||||
|
||||
ContentValues info = data.getParcelableExtra(ListActivity.KEY_INFO);
|
||||
|
||||
if(info == null)
|
||||
info = new ContentValues();
|
||||
/*
|
||||
* package the ringer table information
|
||||
*/
|
||||
info.put(RingerDatabase.KEY_LOCATION_LAT, point.getLatitudeE6());
|
||||
info.put(RingerDatabase.KEY_LOCATION_LON, point.getLongitudeE6());
|
||||
info.put(RingerDatabase.KEY_RADIUS, HowActivity.this.mRadius.getProgress());
|
||||
|
||||
//package the intent
|
||||
data.putExtra(ListActivity.KEY_INFO, info);
|
||||
progress.dismiss();
|
||||
HowActivity.this.startActivityForResult(data, WHAT_REQUEST_CODE);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,7 +39,7 @@ import com.skyhookwireless.wps.RegistrationCallback;
|
||||
import com.skyhookwireless.wps.WPSContinuation;
|
||||
import com.skyhookwireless.wps.WPSReturnCode;
|
||||
|
||||
public class RingerListActivity extends Activity implements OnItemClickListener, OnClickListener, DatabaseListener, RegistrationCallback {
|
||||
public class ListActivity extends Activity implements OnItemClickListener, OnClickListener, DatabaseListener, RegistrationCallback {
|
||||
|
||||
private RingerDatabase mDb;
|
||||
private ListView mListView;
|
||||
@@ -48,6 +48,7 @@ public class RingerListActivity extends Activity implements OnItemClickListener,
|
||||
|
||||
public static final String KEY_RINGER = "key_ringer";
|
||||
public static final String KEY_INFO = "key_info";
|
||||
public static final String KEY_IS_DEFAULT = "key_is_default";
|
||||
private static final int NEW_RINGER = 0;
|
||||
private static final int DELETE_ID = 1;
|
||||
private static final int ACTIVITY_CREATE = 3;
|
||||
@@ -55,6 +56,7 @@ public class RingerListActivity extends Activity implements OnItemClickListener,
|
||||
private static final int SETTINGS = 7;
|
||||
private static final int BACKUP = 8;
|
||||
private static final int RESTORE = 9;
|
||||
private static final String KEY_ROWID = "key_row_id";
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
@@ -89,8 +91,7 @@ public class RingerListActivity extends Activity implements OnItemClickListener,
|
||||
populate();
|
||||
break;
|
||||
case ACTIVITY_EDIT:
|
||||
mDb.updateRinger(intent.getLongExtra(RingerInformationActivity.KEY_ROWID, 0),
|
||||
(ContentValues) intent.getParcelableExtra(KEY_RINGER), (ContentValues) intent.getParcelableExtra(KEY_INFO));
|
||||
mDb.updateRinger(intent.getLongExtra(KEY_ROWID, 1), (ContentValues) intent.getParcelableExtra(KEY_RINGER), (ContentValues) intent.getParcelableExtra(KEY_INFO));
|
||||
populate();
|
||||
break;
|
||||
}
|
||||
@@ -99,7 +100,7 @@ public class RingerListActivity extends Activity implements OnItemClickListener,
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(this, RingerInformationActivity.class);
|
||||
Intent i = new Intent(this, HowActivity.class);
|
||||
startActivityForResult(i, ACTIVITY_CREATE );
|
||||
}
|
||||
|
||||
@@ -226,38 +227,28 @@ public class RingerListActivity extends Activity implements OnItemClickListener,
|
||||
public void run(){
|
||||
Looper.prepare();
|
||||
|
||||
Intent i = new Intent(RingerListActivity.this, RingerInformationActivity.class);
|
||||
Intent i = new Intent(ListActivity.this, HowActivity.class)
|
||||
.putExtra(KEY_ROWID, id+1);
|
||||
|
||||
/*
|
||||
* get the ringer
|
||||
*/
|
||||
Cursor ringer = mDb.getRingerFromId(id+1);
|
||||
if (ringer.moveToFirst()) {
|
||||
i.putExtra(RingerInformationActivity.KEY_ROWID, id+1)
|
||||
.putExtra(RingerDatabase.KEY_RINGER_NAME, ringer.getString(0))
|
||||
.putExtra(RingerDatabase.KEY_IS_ENABLED, ringer.getString(1)== null ? true :(Integer.parseInt(ringer.getString(1)) == 1 ? true : false))//5
|
||||
.putExtra(RingerDatabase.KEY_RADIUS, ringer.getInt(2))
|
||||
.putExtra(RingerDatabase.KEY_LOCATION_LAT, ringer.getInt(3))
|
||||
.putExtra(RingerDatabase.KEY_LOCATION_LON, ringer.getInt(4));
|
||||
}
|
||||
if (ringer.moveToFirst())
|
||||
i.putExtra(RingerDatabase.KEY_RINGER_NAME, ringer.getString(0))
|
||||
.putExtra(RingerDatabase.KEY_IS_ENABLED, RingerDatabase.parseBoolean(ringer.getString(1)));
|
||||
|
||||
if (ringer != null && !ringer.isClosed()) {
|
||||
ringer.close();
|
||||
}
|
||||
|
||||
if(id == 0)
|
||||
i.putExtra(KEY_IS_DEFAULT, true);
|
||||
|
||||
/*
|
||||
* get the ringer's info, and parse it into content values
|
||||
*/
|
||||
ContentValues values = new ContentValues();
|
||||
Cursor info = mDb.getRingerInfo(i.getStringExtra(RingerDatabase.KEY_RINGER_NAME));
|
||||
if (info.moveToFirst()) {
|
||||
do {
|
||||
values.put(info.getString(0), info.getString(1));
|
||||
} while (info.moveToNext());
|
||||
}
|
||||
if (info != null && !info.isClosed()) {
|
||||
info.close();
|
||||
}
|
||||
i.putExtra(KEY_INFO, values);
|
||||
i.putExtra(KEY_INFO, mDb.getRingerInfo(i.getStringExtra(RingerDatabase.KEY_RINGER_NAME)));
|
||||
|
||||
progress.dismiss();
|
||||
|
||||
@@ -278,7 +269,7 @@ public class RingerListActivity extends Activity implements OnItemClickListener,
|
||||
public boolean onOptionsItemSelected (MenuItem item) {
|
||||
switch (item.getItemId()){
|
||||
case NEW_RINGER:
|
||||
Intent i = new Intent(this, RingerInformationActivity.class);
|
||||
Intent i = new Intent(this, WhatActivity.class);
|
||||
startActivityForResult(i, ACTIVITY_CREATE );
|
||||
return true;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package com.TwentyCodes.android.LocationRinger.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ContentValues;
|
||||
@@ -19,68 +20,45 @@ import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.TwentyCodes.android.LocationRinger.LocationSelectedListener;
|
||||
import com.TwentyCodes.android.LocationRinger.R;
|
||||
import com.TwentyCodes.android.LocationRinger.db.RingerDatabase;
|
||||
import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
||||
import com.TwentyCodes.android.SkyHook.SkyHook;
|
||||
import com.TwentyCodes.android.location.GeoPointLocationListener;
|
||||
import com.TwentyCodes.android.location.MapView;
|
||||
import com.google.android.maps.GeoPoint;
|
||||
|
||||
/**
|
||||
* This activity will be used to display all the ringers information, and handle modification to that information
|
||||
* This activity will be used to display what this ringer controls. here the user will be able to add or modify features they wish to control
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class RingerInformationActivity extends com.google.android.maps.MapActivity implements OnCheckedChangeListener, OnClickListener, OnSeekBarChangeListener, GeoPointLocationListener, LocationSelectedListener {
|
||||
public class WhatActivity extends Activity implements OnCheckedChangeListener, OnClickListener {
|
||||
|
||||
public static final String KEY_ROWID = "row_id";
|
||||
private static final int SAVE_ID = 0;
|
||||
private static final String TAG = "RingerInformationActivity";
|
||||
//private static final String TAG = "RingerInformationWhatActivity";
|
||||
private static final int ADD_ID = 1;
|
||||
private SeekBar mRingtonVolume;
|
||||
private SeekBar mRadius;
|
||||
private SeekBar mNotificationRingtoneVolume;
|
||||
private MapView mMapView;
|
||||
private EditText mNotificationRingtone;
|
||||
private EditText mRingerName;
|
||||
private EditText mRingtone;
|
||||
private ToggleButton mNotificationRingtoneToggle;
|
||||
private ToggleButton mRingerToggle;
|
||||
private ToggleButton mRingtoneToggle;
|
||||
private ScrollView mScrollView;
|
||||
private String mRingtoneURI;
|
||||
private String mNotificationRingtoneURI;
|
||||
private ToggleButton mMapEditToggle;
|
||||
private RadiusOverlay mRadiusOverlay;
|
||||
private long mRowID;
|
||||
private ToggleButton mWifiToggle;
|
||||
private ToggleButton mBTToggle;
|
||||
private GeoPoint mPoint;
|
||||
private SeekBar mAlarmVolume;
|
||||
private ProgressBar mMusicVolume;
|
||||
private SkyHook mSkyHook;
|
||||
private ProgressDialog mGpsProgress;
|
||||
private boolean isFirstFix;
|
||||
|
||||
private void addFeature(int item) {
|
||||
String feature = this.getResources().getStringArray(R.array.features)[item];
|
||||
@@ -122,6 +100,14 @@ public class RingerInformationActivity extends com.google.android.maps.MapActivi
|
||||
* @author ricky
|
||||
*/
|
||||
private void displayFeaturesDialog() {
|
||||
|
||||
/*
|
||||
* TODO
|
||||
* Check to see if wifi is available
|
||||
* check to see if bluetooth is available,
|
||||
* remove unavailable options
|
||||
*/
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(this.getText(R.string.add_feature));
|
||||
builder.setItems(R.array.features, new DialogInterface.OnClickListener() {
|
||||
@@ -154,12 +140,6 @@ public class RingerInformationActivity extends com.google.android.maps.MapActivi
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri == null ? null : Uri.parse(uri));
|
||||
startActivityForResult( intent, ringtoneCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRouteDisplayed() {
|
||||
//UNUSED
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the rintone picker activity returns it's result
|
||||
@@ -191,65 +171,28 @@ public class RingerInformationActivity extends com.google.android.maps.MapActivi
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
switch(buttonView.getId()){
|
||||
case R.id.ringer_toggle:
|
||||
this.mRadius.setEnabled(isChecked);
|
||||
this.mRingtone.setEnabled(isChecked);
|
||||
this.mRingtonVolume.setEnabled(isChecked);
|
||||
this.mNotificationRingtone.setEnabled(isChecked);
|
||||
this.mNotificationRingtoneVolume.setEnabled(isChecked);
|
||||
this.mNotificationRingtoneToggle.setEnabled(isChecked);
|
||||
this.mMapView.setEnabled(isChecked);
|
||||
this.mNotificationRingtoneToggle.setEnabled(isChecked);
|
||||
this.mRingtoneToggle.setEnabled(isChecked);
|
||||
this.mMapEditToggle.setEnabled(isChecked);
|
||||
//TODO disable all the child views, or find xml tag to allow setting of child view enabled via parent
|
||||
findViewById(R.id.ringtone_info).setEnabled(isChecked);
|
||||
findViewById(R.id.notification_ringtone_info).setEnabled(isChecked);
|
||||
findViewById(R.id.alarm_volume_info).setEnabled(isChecked);
|
||||
findViewById(R.id.music_volume_info).setEnabled(isChecked);
|
||||
findViewById(R.id.bluetooth_toggle).setEnabled(isChecked);
|
||||
findViewById(R.id.wifi_toggle).setEnabled(isChecked);
|
||||
findViewById(R.id.update_interval_info).setEnabled(isChecked);
|
||||
findViewById(R.id.data_label).setEnabled(isChecked);
|
||||
break;
|
||||
|
||||
case R.id.notification_silent_toggle:
|
||||
findViewById(R.id.notification_ringtone_button).setEnabled(!isChecked);
|
||||
this.mNotificationRingtone.setEnabled(!isChecked);
|
||||
this.mNotificationRingtoneVolume.setEnabled(!isChecked);
|
||||
break;
|
||||
|
||||
case R.id.ringtone_silent_toggle:
|
||||
this.mRingtone.setEnabled(!isChecked);
|
||||
findViewById(R.id.ringtone_button).setEnabled(!isChecked);
|
||||
this.mRingtonVolume.setEnabled(!isChecked);
|
||||
break;
|
||||
|
||||
case R.id.map_edit_toggle:
|
||||
this.isFirstFix = isChecked;
|
||||
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
|
||||
isChecked
|
||||
? (this.getResources().getDisplayMetrics().heightPixels - findViewById(R.id.map_controls).getHeight())
|
||||
: (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 350, getResources().getDisplayMetrics())));
|
||||
if(isChecked){
|
||||
this.mSkyHook.getUpdates();
|
||||
params.addRule(RelativeLayout.ALIGN_PARENT_TOP );
|
||||
this.mGpsProgress = ProgressDialog.show(this, "", this.getText(R.string.gps_fix), true, true);
|
||||
} else {
|
||||
this.mSkyHook.removeUpdates();
|
||||
params.addRule(RelativeLayout.BELOW, R.id.info);
|
||||
params.addRule(RelativeLayout.ALIGN_BOTTOM );
|
||||
if(this.mGpsProgress != null)
|
||||
this.mGpsProgress.dismiss();
|
||||
}
|
||||
findViewById(R.id.map_info).setLayoutParams(params );
|
||||
|
||||
this.mMapView.setDoubleTapZoonEnabled(isChecked);
|
||||
//views
|
||||
findViewById(R.id.info).setVisibility(isChecked ? View.GONE : View.VISIBLE);
|
||||
findViewById(R.id.ringer_options).setVisibility(isChecked ? View.GONE : View.VISIBLE);
|
||||
//buttons
|
||||
findViewById(R.id.mark_my_location).setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
findViewById(R.id.my_location).setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
findViewById(R.id.map_mode).setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
findViewById(R.id.search).setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||
findViewById(R.id.add_feature_button).setVisibility(isChecked ? View.GONE : View.VISIBLE);
|
||||
this.mScrollView.invalidate();
|
||||
this.mScrollView.setScrollEnabled(! isChecked);
|
||||
this.mMapView.setBuiltInZoomControls(isChecked);
|
||||
this.mMapView.setClickable(isChecked);
|
||||
this.mRadius.setEnabled(isChecked);
|
||||
Toast.makeText(this, isChecked ? getString(R.string.map_editing_enabled) : getString(R.string.map_editiing_disabled), Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,22 +212,6 @@ public class RingerInformationActivity extends com.google.android.maps.MapActivi
|
||||
case R.id.save_ringer_button:
|
||||
save();
|
||||
break;
|
||||
case R.id.mark_my_location:
|
||||
if(this.mPoint != null){
|
||||
this.mRadiusOverlay.setLocation(mPoint);
|
||||
this.mMapView.getController().setCenter(mPoint);
|
||||
}
|
||||
break;
|
||||
case R.id.my_location:
|
||||
if(this.mPoint != null)
|
||||
this.mMapView.getController().setCenter(mPoint);
|
||||
break;
|
||||
case R.id.map_mode:
|
||||
this.mMapView.setSatellite(mMapView.isSatellite() ? false : true);
|
||||
break;
|
||||
case R.id.search:
|
||||
new SearchDialog(this, this).show();
|
||||
break;
|
||||
case R.id.add_feature_button:
|
||||
findViewById(R.id.add_a_feature_label).setVisibility(View.GONE);
|
||||
displayFeaturesDialog();
|
||||
@@ -300,42 +227,18 @@ public class RingerInformationActivity extends com.google.android.maps.MapActivi
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
/*
|
||||
* TODO
|
||||
* Check to see if wifi is available
|
||||
* check to see if bluetooth is available,
|
||||
* remove unavailable options
|
||||
*/
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
this.setContentView(R.layout.ringer_info);
|
||||
this.setContentView(R.layout.what);
|
||||
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
|
||||
AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
|
||||
this.mSkyHook = new SkyHook(this);
|
||||
this.mSkyHook.setLocationListener(this);
|
||||
|
||||
this.mScrollView = (ScrollView) findViewById(R.id.scrollview);
|
||||
|
||||
this.mRingerName = (EditText) findViewById(R.id.ringer_name);
|
||||
this.mRingerToggle = (ToggleButton) findViewById(R.id.ringer_toggle);
|
||||
this.mRingerToggle.setChecked(true);
|
||||
this.mRingerToggle.setOnCheckedChangeListener(this);
|
||||
|
||||
this.mMapView = (MapView) findViewById(R.id.mapview);
|
||||
this.mRadius = (SeekBar) findViewById(R.id.radius);
|
||||
this.mRadius.setMax(Debug.MAX_RADIUS_IN_METERS);
|
||||
this.mMapView.setClickable(false);
|
||||
this.mMapEditToggle = (ToggleButton) findViewById(R.id.map_edit_toggle);
|
||||
this.mMapEditToggle.setChecked(false);
|
||||
this.mMapEditToggle.setOnCheckedChangeListener(this);
|
||||
this.mRadiusOverlay = new RadiusOverlay();
|
||||
this.mRadius.setOnSeekBarChangeListener(this);
|
||||
this.mMapView.getOverlays().add(mRadiusOverlay);
|
||||
this.mRadius.setEnabled(false);
|
||||
|
||||
this.mRingtone = (EditText) findViewById(R.id.ringtone);
|
||||
this.mRingtoneToggle = (ToggleButton) findViewById(R.id.ringtone_silent_toggle);
|
||||
this.mRingtonVolume = (SeekBar) findViewById(R.id.ringtone_volume);
|
||||
@@ -396,20 +299,32 @@ public class RingerInformationActivity extends com.google.android.maps.MapActivi
|
||||
|
||||
Intent data = this.getIntent();
|
||||
|
||||
if(data.hasExtra(KEY_ROWID)){
|
||||
if(data.hasExtra(ListActivity.KEY_INFO)){
|
||||
|
||||
this.mRowID = data.getLongExtra(KEY_ROWID, 0);
|
||||
this.mRingerToggle.setChecked(data.getBooleanExtra(RingerDatabase.KEY_IS_ENABLED, true));
|
||||
this.mRadiusOverlay.setLocation(new GeoPoint(data.getIntExtra(RingerDatabase.KEY_LOCATION_LAT, 0), data.getIntExtra(RingerDatabase.KEY_LOCATION_LON, 0)));
|
||||
this.mRadius.setProgress(data.getIntExtra(RingerDatabase.KEY_RADIUS, 0));
|
||||
this.mRingerName.setText(data.getStringExtra(RingerDatabase.KEY_RINGER_NAME));
|
||||
this.setTitle(getString(R.string.editing)+" "+mRingerName.getText().toString());
|
||||
|
||||
|
||||
/*
|
||||
* if this is the default ringer, then we will display everything
|
||||
*/
|
||||
if(data.getBooleanExtra(ListActivity.KEY_IS_DEFAULT, false)){
|
||||
findViewById(R.id.ringer_options).setVisibility(View.GONE);
|
||||
findViewById(R.id.notification_ringtone_info).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.ringtone_info).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.wifi_toggle).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.data_label).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.bluetooth_toggle).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.music_volume_info).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.alarm_volume_info).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.update_interval_info).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.add_feature_button).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
/*
|
||||
* We need to null check all the values
|
||||
*/
|
||||
ContentValues info = (ContentValues) data.getParcelableExtra(RingerListActivity.KEY_INFO);
|
||||
ContentValues info = (ContentValues) data.getParcelableExtra(ListActivity.KEY_INFO);
|
||||
|
||||
if(RingerDatabase.parseBoolean(info.getAsString(RingerDatabase.KEY_PLUS_BUTTON_HINT)));
|
||||
findViewById(R.id.add_a_feature_label).setVisibility(View.GONE);
|
||||
@@ -482,29 +397,6 @@ public class RingerInformationActivity extends com.google.android.maps.MapActivi
|
||||
} else
|
||||
this.setTitle(R.string.new_ringer);
|
||||
|
||||
if(this.mRadiusOverlay.getLocation() != null){
|
||||
this.mMapView.getController().setCenter(this.mRadiusOverlay.getLocation());
|
||||
this.mMapView.getController().setZoom(16);
|
||||
}
|
||||
|
||||
if(this.mRingerName.getText().toString().equals(getString(R.string.default_ringer))){
|
||||
this.mMapView.setEnabled(false);
|
||||
this.mMapEditToggle.setEnabled(false);
|
||||
this.mRingerName.setEnabled(false);
|
||||
this.mRingerToggle.setEnabled(false);
|
||||
findViewById(R.id.ringer_options).setVisibility(View.GONE);
|
||||
findViewById(R.id.map_info).setVisibility(View.GONE);
|
||||
findViewById(R.id.notification_ringtone_info).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.ringtone_info).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.wifi_toggle).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.data_label).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.bluetooth_toggle).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.music_volume_info).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.alarm_volume_info).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.update_interval_info).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
this.mMapView.setDoubleTapZoonEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -518,66 +410,6 @@ public class RingerInformationActivity extends com.google.android.maps.MapActivi
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.android.maps.MapActivity#onDestroy()
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
this.mSkyHook.removeUpdates();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when skyhook has a location to report
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public void onLocationChanged(GeoPoint point, int accuracy) {
|
||||
this.mPoint = point;
|
||||
|
||||
if(point != null){
|
||||
|
||||
/*
|
||||
* if this is the first fix and the radius overlay does not have a point specified
|
||||
* then pan the map, and zoom in to the users current location
|
||||
*/
|
||||
if(this.isFirstFix)
|
||||
if(this.mRadiusOverlay.getLocation() == null){
|
||||
if(this.mMapView != null){
|
||||
this.mMapView.getController().setCenter(point);
|
||||
this.mMapView.getController().setZoom((this.mMapView.getMaxZoomLevel() - 5));
|
||||
}
|
||||
this.isFirstFix = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* dismiss the acquiring gps dialog
|
||||
*/
|
||||
if(this.mGpsProgress != null)
|
||||
this.mGpsProgress.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
@Override
|
||||
public void onLocationSelected(GeoPoint point) {
|
||||
if(point != null){
|
||||
if(Debug.DEBUG)
|
||||
Log.d(TAG, "onLocationSelected() "+ point.toString());
|
||||
|
||||
if(this.mRadiusOverlay != null)
|
||||
this.mRadiusOverlay.setLocation(point);
|
||||
|
||||
if(this.mMapView != null){
|
||||
this.mMapView.getController().setCenter(point);
|
||||
this.mMapView.getController().setZoom((this.mMapView.getMaxZoomLevel() - 5));
|
||||
}
|
||||
} else if(Debug.DEBUG)
|
||||
Log.d(TAG, "onLocationSelected() Location was null");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
|
||||
* @author ricky barrette
|
||||
@@ -595,30 +427,6 @@ public class RingerInformationActivity extends com.google.android.maps.MapActivi
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a seekbar is has its progress changed
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
switch (seekBar.getId()){
|
||||
case R.id.radius:
|
||||
this.mRadiusOverlay.setRadius(progress);
|
||||
this.mMapView.invalidate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
//UNUSED
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
//UNUSED
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a bundle containing all the information that needs to be saved, and returns it to the starting activity
|
||||
* @author ricky barrette
|
||||
@@ -632,68 +440,64 @@ public class RingerInformationActivity extends com.google.android.maps.MapActivi
|
||||
public void run(){
|
||||
Looper.prepare();
|
||||
|
||||
Intent data = new Intent();
|
||||
GeoPoint point = RingerInformationActivity.this.mRadiusOverlay.getLocation();
|
||||
Intent data = new Intent().putExtras(WhatActivity.this.getIntent());
|
||||
|
||||
//to prevent null pointers
|
||||
if(point == null)
|
||||
point = new GeoPoint(0,0);
|
||||
ContentValues ringer = WhatActivity.this.getIntent().getParcelableExtra(ListActivity.KEY_RINGER);
|
||||
ContentValues info = WhatActivity.this.getIntent().getParcelableExtra(ListActivity.KEY_INFO);
|
||||
|
||||
if(RingerInformationActivity.this.mRowID > 0)
|
||||
data.putExtra(KEY_ROWID, mRowID);
|
||||
if(ringer == null)
|
||||
ringer = new ContentValues();
|
||||
|
||||
ContentValues ringer = new ContentValues();
|
||||
ContentValues info = new ContentValues();
|
||||
if(info == null)
|
||||
info = new ContentValues();
|
||||
|
||||
/*
|
||||
* package the ringer table information
|
||||
*/
|
||||
ringer.put(RingerDatabase.KEY_RINGER_NAME, RingerInformationActivity.this.mRingerName.getText().toString());
|
||||
ringer.put(RingerDatabase.KEY_IS_ENABLED, RingerInformationActivity.this.mRingerToggle.isChecked());
|
||||
ringer.put(RingerDatabase.KEY_LOCATION_LAT, point.getLatitudeE6());
|
||||
ringer.put(RingerDatabase.KEY_LOCATION_LON, point.getLongitudeE6());
|
||||
ringer.put(RingerDatabase.KEY_RADIUS, RingerInformationActivity.this.mRadius.getProgress());
|
||||
ringer.put(RingerDatabase.KEY_RINGER_NAME, WhatActivity.this.mRingerName.getText().toString());
|
||||
ringer.put(RingerDatabase.KEY_IS_ENABLED, WhatActivity.this.mRingerToggle.isChecked());
|
||||
|
||||
/*
|
||||
* package the ringer_info table information
|
||||
*/
|
||||
if(findViewById(R.id.notification_ringtone_info).isShown()){
|
||||
info.put(RingerDatabase.KEY_NOTIFICATION_IS_SILENT, RingerInformationActivity.this.mNotificationRingtoneToggle.isChecked());
|
||||
info.put(RingerDatabase.KEY_NOTIFICATION_RINGTONE, RingerInformationActivity.this.mNotificationRingtone.getText().toString());
|
||||
info.put(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI, RingerInformationActivity.this.mNotificationRingtoneURI);
|
||||
info.put(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME, RingerInformationActivity.this.mNotificationRingtoneVolume.getProgress());
|
||||
info.put(RingerDatabase.KEY_NOTIFICATION_IS_SILENT, WhatActivity.this.mNotificationRingtoneToggle.isChecked());
|
||||
info.put(RingerDatabase.KEY_NOTIFICATION_RINGTONE, WhatActivity.this.mNotificationRingtone.getText().toString());
|
||||
info.put(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI, WhatActivity.this.mNotificationRingtoneURI);
|
||||
info.put(RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME, WhatActivity.this.mNotificationRingtoneVolume.getProgress());
|
||||
}
|
||||
|
||||
if(findViewById(R.id.ringtone_info).isShown()){
|
||||
info.put(RingerDatabase.KEY_RINGTONE, RingerInformationActivity.this.mRingtone.getText().toString());
|
||||
info.put(RingerDatabase.KEY_RINGTONE_IS_SILENT, RingerInformationActivity.this.mRingtoneToggle.isChecked());
|
||||
info.put(RingerDatabase.KEY_RINGTONE_URI, RingerInformationActivity.this.mRingtoneURI);
|
||||
info.put(RingerDatabase.KEY_RINGTONE_VOLUME, RingerInformationActivity.this.mRingtonVolume.getProgress());
|
||||
info.put(RingerDatabase.KEY_RINGTONE, WhatActivity.this.mRingtone.getText().toString());
|
||||
info.put(RingerDatabase.KEY_RINGTONE_IS_SILENT, WhatActivity.this.mRingtoneToggle.isChecked());
|
||||
info.put(RingerDatabase.KEY_RINGTONE_URI, WhatActivity.this.mRingtoneURI);
|
||||
info.put(RingerDatabase.KEY_RINGTONE_VOLUME, WhatActivity.this.mRingtonVolume.getProgress());
|
||||
}
|
||||
|
||||
if(findViewById(R.id.wifi_toggle).isShown())
|
||||
info.put(RingerDatabase.KEY_WIFI, RingerInformationActivity.this.mWifiToggle.isChecked());
|
||||
info.put(RingerDatabase.KEY_WIFI, WhatActivity.this.mWifiToggle.isChecked());
|
||||
|
||||
if(findViewById(R.id.bluetooth_toggle).isShown())
|
||||
info.put(RingerDatabase.KEY_BT, RingerInformationActivity.this.mBTToggle.isChecked());
|
||||
info.put(RingerDatabase.KEY_BT, WhatActivity.this.mBTToggle.isChecked());
|
||||
|
||||
if(findViewById(R.id.music_volume_info).isShown())
|
||||
info.put(RingerDatabase.KEY_MUSIC_VOLUME, RingerInformationActivity.this.mMusicVolume.getProgress());
|
||||
info.put(RingerDatabase.KEY_MUSIC_VOLUME, WhatActivity.this.mMusicVolume.getProgress());
|
||||
|
||||
if(findViewById(R.id.alarm_volume_info).isShown())
|
||||
info.put(RingerDatabase.KEY_ALARM_VOLUME, RingerInformationActivity.this.mAlarmVolume.getProgress());
|
||||
info.put(RingerDatabase.KEY_ALARM_VOLUME, WhatActivity.this.mAlarmVolume.getProgress());
|
||||
|
||||
if(findViewById(R.id.update_interval_info).isShown())
|
||||
info.put(RingerDatabase.KEY_UPDATE_INTERVAL,
|
||||
RingerInformationActivity.this.getResources().getStringArray(R.array.runtimes)[((Spinner) findViewById(R.id.update_interval)).getSelectedItemPosition()]);
|
||||
WhatActivity.this.getResources().getStringArray(R.array.runtimes)[((Spinner) findViewById(R.id.update_interval)).getSelectedItemPosition()]);
|
||||
|
||||
info.put(RingerDatabase.KEY_PLUS_BUTTON_HINT, true);
|
||||
|
||||
//package the intent
|
||||
data.putExtra(RingerListActivity.KEY_RINGER, ringer).putExtra(RingerListActivity.KEY_INFO, info);
|
||||
RingerInformationActivity.this.setResult(RESULT_OK, data);
|
||||
data.putExtra(ListActivity.KEY_RINGER, ringer).putExtra(ListActivity.KEY_INFO, info);
|
||||
|
||||
WhatActivity.this.setResult(RESULT_OK, data);
|
||||
progress.dismiss();
|
||||
RingerInformationActivity.this.finish();
|
||||
WhatActivity.this.finish();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
Reference in New Issue
Block a user