Added a Seach Requested Listener
and implmented the search listener in LocationInfomationFragment to allow it to handle search requests from the hardware button closes #69 Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* SearchRequestedListener.java
|
||||
* @date May 31, 2012
|
||||
* @author ricky barrette
|
||||
* @author Twenty Codes, LLC
|
||||
*/
|
||||
package com.TwentyCodes.android.LocationRinger;
|
||||
|
||||
/**
|
||||
* A simple interface to allow a compent other than an activity to handle a seach event
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public interface SearchRequestedListener {
|
||||
|
||||
/**
|
||||
* Called when the a seach is request via seach button
|
||||
* @return
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public boolean onSearchRequested();
|
||||
}
|
||||
@@ -48,6 +48,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
private ContentValues mInfo;
|
||||
private Intent mData;
|
||||
private ViewPager mPager;
|
||||
private LocationInfomationFragment mLocationInfomationFragment;
|
||||
|
||||
/**
|
||||
* Logs the content values
|
||||
@@ -58,7 +59,6 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
for(Entry<String,Object> item : values.valueSet())
|
||||
Log.d(TAG, item.getKey() +" = "+ item.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity is first created
|
||||
* (non-Javadoc)
|
||||
@@ -109,8 +109,10 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
/*
|
||||
* Location page
|
||||
*/
|
||||
if(!isDefault)
|
||||
fragments.add(new LocationInfomationFragment(this.mInfo, this, this));
|
||||
if(!isDefault){
|
||||
this.mLocationInfomationFragment = new LocationInfomationFragment(this.mInfo, this, this);
|
||||
fragments.add(this.mLocationInfomationFragment);
|
||||
}
|
||||
|
||||
fragments.add(new FeatureListFragment(this.mInfo, this));
|
||||
|
||||
@@ -126,7 +128,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
|
||||
indicator.setOnPageChangeListener(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the main menu that is displayed when the menu button is clicked
|
||||
* @author ricky barrette
|
||||
@@ -136,7 +138,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
inflater.inflate(R.menu.ringer_info_menu, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the ringer info has changed
|
||||
* (non-Javadoc)
|
||||
@@ -150,6 +152,18 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
}
|
||||
this.mInfo.putAll(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a feature is removed
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.LocationRinger.OnContentChangedListener#onInfoContentRemoved(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void onInfoContentRemoved(String... keys) {
|
||||
for(String key : keys)
|
||||
if(this.mInfo.containsKey(key))
|
||||
this.mInfo.remove(key);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
|
||||
@@ -205,6 +219,17 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
this.mRinger.putAll(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.app.Activity#onSearchRequested()
|
||||
*/
|
||||
@Override
|
||||
public boolean onSearchRequested() {
|
||||
if(this.mLocationInfomationFragment != null && this.mPager.getCurrentItem() == 1)
|
||||
return this.mLocationInfomationFragment.onSearchRequested();
|
||||
return super.onSearchRequested();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a bundle containing all the information that needs to be saved, and returns it to the starting activity
|
||||
* @author ricky barrette
|
||||
@@ -224,7 +249,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the scrolling state of the view pager is changed
|
||||
* (non-Javadoc)
|
||||
@@ -235,16 +260,4 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
this.mPager.setScrollEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a feature is removed
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.LocationRinger.OnContentChangedListener#onInfoContentRemoved(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void onInfoContentRemoved(String... keys) {
|
||||
for(String key : keys)
|
||||
if(this.mInfo.containsKey(key))
|
||||
this.mInfo.remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import android.widget.ToggleButton;
|
||||
import com.TwentyCodes.android.LocationRinger.EnableScrollingListener;
|
||||
import com.TwentyCodes.android.LocationRinger.OnContentChangedListener;
|
||||
import com.TwentyCodes.android.LocationRinger.R;
|
||||
import com.TwentyCodes.android.LocationRinger.SearchRequestedListener;
|
||||
import com.TwentyCodes.android.LocationRinger.db.RingerDatabase;
|
||||
import com.TwentyCodes.android.LocationRinger.debug.Debug;
|
||||
import com.TwentyCodes.android.LocationRinger.ui.SearchDialog;
|
||||
@@ -37,7 +38,7 @@ import com.google.android.maps.GeoPoint;
|
||||
* This fragment will be used to display and allow the user to edit the ringers location trigger
|
||||
* @author ricky
|
||||
*/
|
||||
public class LocationInfomationFragment extends Fragment implements GeoPointLocationListener, OnClickListener, OnCheckedChangeListener, OnSeekBarChangeListener, OnLocationSelectedListener {
|
||||
public class LocationInfomationFragment extends Fragment implements GeoPointLocationListener, OnClickListener, OnCheckedChangeListener, OnSeekBarChangeListener, OnLocationSelectedListener, SearchRequestedListener {
|
||||
|
||||
private ContentValues mInfo;
|
||||
private OnContentChangedListener mListener;
|
||||
@@ -114,69 +115,6 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.android.maps.MapActivity#onDestroy()
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public void onStop() {
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
@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.mMap != null){
|
||||
this.mMap.setMapCenter(point);
|
||||
this.mMap.setZoom((this.mMap.getMap().getMaxZoomLevel() - 5));
|
||||
}
|
||||
|
||||
if(this.mListener != null){
|
||||
ContentValues info = new ContentValues();
|
||||
info.put(RingerDatabase.KEY_LOCATION, point.toString());
|
||||
this.mListener.onInfoContentChanged(info);
|
||||
}
|
||||
} else if(Debug.DEBUG)
|
||||
Log.d(TAG, "onLocationSelected() Location was null");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.mMap.invalidate();
|
||||
if(this.mListener != null){
|
||||
ContentValues info = new ContentValues();
|
||||
info.put(RingerDatabase.KEY_RADIUS, progress);
|
||||
this.mListener.onInfoContentChanged(info);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
view = inflater.inflate(R.layout.map_info_fragment, container, false);
|
||||
@@ -221,39 +159,6 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.support.v4.app.Fragment#onPause()
|
||||
*/
|
||||
@Override
|
||||
public void onPause() {
|
||||
mSkyHook.removeUpdates();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.support.v4.app.Fragment#onResume()
|
||||
*/
|
||||
@Override
|
||||
public void onResume() {
|
||||
if(mMapEditToggle.isChecked())
|
||||
mSkyHook.getUpdates();
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the location is a first fix
|
||||
* (non-Javadoc)
|
||||
@@ -282,4 +187,110 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Called when skyhook has a location to report
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public void onLocationChanged(GeoPoint point, int accuracy) {
|
||||
this.mPoint = point;
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
@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.mMap != null){
|
||||
this.mMap.setMapCenter(point);
|
||||
this.mMap.setZoom((this.mMap.getMap().getMaxZoomLevel() - 5));
|
||||
}
|
||||
|
||||
if(this.mListener != null){
|
||||
ContentValues info = new ContentValues();
|
||||
info.put(RingerDatabase.KEY_LOCATION, point.toString());
|
||||
this.mListener.onInfoContentChanged(info);
|
||||
}
|
||||
} else if(Debug.DEBUG)
|
||||
Log.d(TAG, "onLocationSelected() Location was null");
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.support.v4.app.Fragment#onPause()
|
||||
*/
|
||||
@Override
|
||||
public void onPause() {
|
||||
mSkyHook.removeUpdates();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.mMap.invalidate();
|
||||
if(this.mListener != null){
|
||||
ContentValues info = new ContentValues();
|
||||
info.put(RingerDatabase.KEY_RADIUS, progress);
|
||||
this.mListener.onInfoContentChanged(info);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see android.support.v4.app.Fragment#onResume()
|
||||
*/
|
||||
@Override
|
||||
public void onResume() {
|
||||
if(mMapEditToggle.isChecked())
|
||||
mSkyHook.getUpdates();
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.LocationRinger.SearchRequestedListener#onSearchRequested()
|
||||
*/
|
||||
@Override
|
||||
public boolean onSearchRequested() {
|
||||
new SearchDialog(this.getActivity(), this).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.android.maps.MapActivity#onDestroy()
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public void onStop() {
|
||||
this.mSkyHook.removeUpdates();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user