Working again.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
android:versionCode="248"
|
||||
android:versionName="8cc52de" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="11" />
|
||||
<uses-sdk android:minSdkVersion="17" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.location"
|
||||
@@ -32,6 +32,7 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
|
||||
<!-- licensing library -->
|
||||
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
|
||||
|
||||
@@ -48,12 +48,12 @@
|
||||
android:visibility="gone" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/mapview"
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/buttons"
|
||||
android:layout_below="@id/map_controls"
|
||||
class="org.RickBarrette.android.LocationRinger.ui.fragments.MapFragment" >
|
||||
class="com.google.android.gms.maps.SupportMapFragment" >
|
||||
</fragment>
|
||||
|
||||
<TextView
|
||||
@@ -61,7 +61,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@+id/mapview"
|
||||
android:layout_alignTop="@+id/map"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="#ff0000" />
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.provider.Settings;
|
||||
import com.TwentyCodes.android.debug.LocationLibraryConstants;
|
||||
import com.TwentyCodes.android.exception.ExceptionHandler;
|
||||
import com.TwentyCodes.android.location.GeoUtils;
|
||||
@@ -133,17 +132,19 @@ public class RingerProcessingService extends Service {
|
||||
|
||||
/*
|
||||
* airplane mode
|
||||
*
|
||||
* TODO fix airplane mode or remove it
|
||||
*/
|
||||
if (values.containsKey(RingerDatabase.KEY_AIRPLANE_MODE)) {
|
||||
final boolean airplaneModeEnabled = !RingerDatabase.parseBoolean(values.getAsString(RingerDatabase.KEY_AIRPLANE_MODE));
|
||||
// toggle airplane mode
|
||||
Log.d(TAG, "airplane mode has be set " + Settings.System.putInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, airplaneModeEnabled ? 0 : 1));
|
||||
|
||||
// Post an intent to reload
|
||||
final Intent changeMode = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||
changeMode.putExtra("state", !airplaneModeEnabled);
|
||||
this.sendBroadcast(changeMode);
|
||||
}
|
||||
// if (values.containsKey(RingerDatabase.KEY_AIRPLANE_MODE)) {
|
||||
// final boolean airplaneModeEnabled = !RingerDatabase.parseBoolean(values.getAsString(RingerDatabase.KEY_AIRPLANE_MODE));
|
||||
// // toggle airplane mode
|
||||
// Log.d(TAG, "airplane mode has be set " + Settings.Global.getInt(getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, airplaneModeEnabled ? 0 : 1));
|
||||
//
|
||||
// // Post an intent to reload
|
||||
// final Intent changeMode = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||
// changeMode.putExtra("state", !airplaneModeEnabled);
|
||||
// this.sendBroadcast(changeMode);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -239,7 +239,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
info.put(RingerDatabase.KEY_RINGTONE_VOLUME, am.getStreamVolume(AudioManager.STREAM_RING));
|
||||
info.put(RingerDatabase.KEY_BT, bt.isEnabled());
|
||||
info.put(RingerDatabase.KEY_WIFI, wifi.isWifiEnabled());
|
||||
info.put(RingerDatabase.KEY_AIRPLANE_MODE, Settings.System.getInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0);
|
||||
info.put(RingerDatabase.KEY_AIRPLANE_MODE, Settings.System.getInt(getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0);
|
||||
|
||||
new Handler().post(new Runnable() {
|
||||
@Override
|
||||
@@ -296,7 +296,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
@Override
|
||||
public void onItemClick(final AdapterView<?> arg0, final View v, final int postion, final long id) {
|
||||
|
||||
final ProgressDialog progress = null; //ProgressDialog.show(this.getParent(), "", getText(R.string.loading), true, true);
|
||||
// final ProgressDialog progress = ProgressDialog.show(this.getParent(), "", getText(R.string.loading), true, true);
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
@@ -327,7 +327,7 @@ public class ListActivity extends Activity implements OnItemClickListener, OnCli
|
||||
i.putExtra(KEY_INFO, mDb.getRingerInfo(r.getAsString(RingerDatabase.KEY_RINGER_NAME)));
|
||||
}
|
||||
|
||||
progress.dismiss();
|
||||
// progress.dismiss();
|
||||
|
||||
// start the ringer info activity in editor mode
|
||||
startActivityForResult(i, ACTIVITY_EDIT);
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.RickBarrette.android.LocationRinger.R;
|
||||
import org.RickBarrette.android.LocationRinger.db.RingerDatabase;
|
||||
import org.RickBarrette.android.LocationRinger.ui.fragments.AboutRingerFragment;
|
||||
import org.RickBarrette.android.LocationRinger.ui.fragments.FeatureListFragment;
|
||||
import org.RickBarrette.android.LocationRinger.ui.fragments.LocationInfomationFragment;
|
||||
import org.RickBarrette.android.LocationRinger.ui.fragments.LocationInformationFragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
@@ -51,7 +51,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
private ContentValues mInfo;
|
||||
private Intent mData;
|
||||
private ViewPager mPager;
|
||||
private LocationInfomationFragment mLocationInfomationFragment;
|
||||
private LocationInformationFragment mLocationInfomationFragment;
|
||||
|
||||
/**
|
||||
* Logs the content values
|
||||
@@ -119,7 +119,7 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon
|
||||
* Location page
|
||||
*/
|
||||
if (!isDefault) {
|
||||
mLocationInfomationFragment = new LocationInfomationFragment(mInfo, this, this);
|
||||
mLocationInfomationFragment = new LocationInformationFragment(mInfo, this, this);
|
||||
fragments.add(mLocationInfomationFragment);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.RickBarrette.android.LocationRinger.ui.fragments;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentValues;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -21,10 +22,11 @@ import com.TwentyCodes.android.location.AndroidGPS;
|
||||
import com.TwentyCodes.android.location.GeoUtils;
|
||||
import com.TwentyCodes.android.location.LatLngListener;
|
||||
import com.TwentyCodes.android.location.OnLocationSelectedListener;
|
||||
import com.TwentyCodes.android.overlays.RadiusOverlay;
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.MapFragment;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.Circle;
|
||||
import com.google.android.gms.maps.model.CircleOptions;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import org.RickBarrette.android.LocationRinger.*;
|
||||
import org.RickBarrette.android.LocationRinger.db.RingerDatabase;
|
||||
@@ -37,28 +39,27 @@ import org.RickBarrette.android.LocationRinger.ui.SearchDialog;
|
||||
* @author ricky
|
||||
*/
|
||||
@SuppressLint("ValidFragment")
|
||||
public class LocationInfomationFragment extends Fragment implements LatLngListener, OnClickListener, OnCheckedChangeListener, OnSeekBarChangeListener,
|
||||
OnLocationSelectedListener, SearchRequestedListener {
|
||||
public class LocationInformationFragment extends Fragment implements LatLngListener, OnClickListener, OnCheckedChangeListener, OnSeekBarChangeListener, SearchRequestedListener, GoogleMap.OnMapClickListener, OnLocationSelectedListener {
|
||||
|
||||
private static final String TAG = "RingerInformationHowActivity";
|
||||
private final ContentValues mInfo;
|
||||
private final OnContentChangedListener mListener;
|
||||
private final EnableScrollingListener mEnableScrollingListener;
|
||||
private SeekBar mRadius;
|
||||
private MapFragment mMap;
|
||||
private GoogleMap mMap;
|
||||
private ToggleButton mMapEditToggle;
|
||||
private RadiusOverlay mRadiusOverlay;
|
||||
private LatLng mPoint;
|
||||
private AndroidGPS mGPS;
|
||||
private View view;
|
||||
private TextView mRadiusTextView;
|
||||
private Circle mCircle;
|
||||
|
||||
/**
|
||||
* Creates a new MapFragment
|
||||
*
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public LocationInfomationFragment(final ContentValues info, final OnContentChangedListener listener, final EnableScrollingListener enabledListener) {
|
||||
public LocationInformationFragment(final ContentValues info, final OnContentChangedListener listener, final EnableScrollingListener enabledListener) {
|
||||
mInfo = info;
|
||||
mListener = listener;
|
||||
mEnableScrollingListener = enabledListener;
|
||||
@@ -76,14 +77,16 @@ public class LocationInfomationFragment extends Fragment implements LatLngListen
|
||||
if (mEnableScrollingListener != null)
|
||||
mEnableScrollingListener.setScrollEnabled(!isChecked);
|
||||
|
||||
// /*if (isChecked) {
|
||||
// mGPS.enableLocationUpdates(this);
|
||||
if (isChecked) {
|
||||
mGPS.enableLocationUpdates(this);
|
||||
// mMap.enableGPSProgess();
|
||||
// } else {
|
||||
// mGPS.disableLocationUpdates();
|
||||
mMap.setOnMapClickListener(this);
|
||||
} else {
|
||||
mGPS.disableLocationUpdates();
|
||||
// mMap.disableGPSProgess();
|
||||
// }
|
||||
//
|
||||
mMap.setOnMapClickListener(null);
|
||||
}
|
||||
|
||||
// mMap.setDoubleTapZoonEnabled(isChecked);
|
||||
// // buttons
|
||||
// mMap.setBuiltInZoomControls(isChecked);
|
||||
@@ -102,14 +105,14 @@ public class LocationInfomationFragment extends Fragment implements LatLngListen
|
||||
switch (v.getId()) {
|
||||
case R.id.mark_my_location:
|
||||
if (mPoint != null)
|
||||
onLocationSelected(mPoint);
|
||||
onMapClick(mPoint);
|
||||
break;
|
||||
case R.id.my_location:
|
||||
if (mPoint != null)
|
||||
mMap.getMap().moveCamera(CameraUpdateFactory.newLatLng(mPoint));
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLng(mPoint));
|
||||
break;
|
||||
case R.id.map_mode:
|
||||
mMap.getMap().setMapType(mMap.getMap().getMapType() == GoogleMap.MAP_TYPE_NORMAL ? GoogleMap.MAP_TYPE_NORMAL : GoogleMap.MAP_TYPE_SATELLITE);
|
||||
mMap.setMapType(mMap.getMapType() == GoogleMap.MAP_TYPE_NORMAL ? GoogleMap.MAP_TYPE_SATELLITE : GoogleMap.MAP_TYPE_NORMAL);
|
||||
break;
|
||||
case R.id.search:
|
||||
new SearchDialog(getActivity(), this).show();
|
||||
@@ -120,10 +123,10 @@ public class LocationInfomationFragment extends Fragment implements LatLngListen
|
||||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
view = inflater.inflate(R.layout.map_info_fragment, container, false);
|
||||
setUpMapIfNeeded();
|
||||
|
||||
mGPS = new AndroidGPS(getActivity());
|
||||
|
||||
// mMap = (MapFragment) getFragmentManager().findFragmentById(R.id.mapview);
|
||||
mRadius = (SeekBar) view.findViewById(R.id.radius);
|
||||
mRadiusTextView = (TextView) view.findViewById(R.id.radius_textview);
|
||||
mRadius.setMax(Constraints.MAX_RADIUS_IN_METERS);
|
||||
@@ -134,29 +137,22 @@ public class LocationInfomationFragment extends Fragment implements LatLngListen
|
||||
mMapEditToggle = (ToggleButton) view.findViewById(R.id.map_edit_toggle);
|
||||
mMapEditToggle.setChecked(false);
|
||||
mMapEditToggle.setOnCheckedChangeListener(this);
|
||||
mRadiusOverlay = new RadiusOverlay();
|
||||
mRadiusOverlay.setLocationSelectedListener(this);
|
||||
|
||||
mRadius.setOnSeekBarChangeListener(this);
|
||||
mMap.getMap().addCircle(mRadiusOverlay.getCircleOptions());
|
||||
mRadius.setEnabled(false);
|
||||
|
||||
if (mInfo.get(RingerDatabase.KEY_LOCATION) != null) {
|
||||
final String[] point = mInfo.getAsString(RingerDatabase.KEY_LOCATION).split(",");
|
||||
mRadiusOverlay.setLocation(new LatLng(Integer.parseInt(point[0]), Integer.parseInt(point[1])));
|
||||
final LatLng location = new LatLng(Double.parseDouble(point[0]), Double.parseDouble(point[1]));
|
||||
|
||||
mCircle.setCenter(location);
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 14));
|
||||
}
|
||||
|
||||
if (mInfo.get(RingerDatabase.KEY_RADIUS) != null)
|
||||
if (mInfo.get(RingerDatabase.KEY_RADIUS) != null) {
|
||||
mRadius.setProgress(mInfo.getAsInteger(RingerDatabase.KEY_RADIUS));
|
||||
|
||||
if (mRadiusOverlay.getLocation() != null) {
|
||||
mMap.getMap().moveCamera(CameraUpdateFactory.newLatLng(mRadiusOverlay.getLocation()));
|
||||
//todo zoom
|
||||
// mMap.setZoom(16);
|
||||
}
|
||||
|
||||
//
|
||||
// mMap.setDoubleTapZoonEnabled(false);
|
||||
|
||||
view.findViewById(R.id.my_location).setOnClickListener(this);
|
||||
view.findViewById(R.id.mark_my_location).setOnClickListener(this);
|
||||
view.findViewById(R.id.search).setOnClickListener(this);
|
||||
@@ -174,26 +170,25 @@ public class LocationInfomationFragment extends Fragment implements LatLngListen
|
||||
*/
|
||||
@Override
|
||||
public void onFirstFix(final boolean isFirstFix) {
|
||||
// if (mPoint != 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 (isFirstFix) {
|
||||
if (mPoint != 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 (isFirstFix) {
|
||||
// mMap.disableGPSProgess();
|
||||
// if (mRadiusOverlay.getLocation() == null)
|
||||
// if (mMap != null) {
|
||||
// mMap.setMapCenter(mPoint);
|
||||
// mMap.setZoom(mMap.getMap().getMaxZoomLevel() - 5);
|
||||
// }
|
||||
// }
|
||||
// } else
|
||||
if (mMap != null) {
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mPoint, 14));
|
||||
}
|
||||
}
|
||||
}
|
||||
// else
|
||||
// mMap.enableGPSProgess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when skyhook has a location to report
|
||||
* Called when the GPS has a location to report
|
||||
*
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@@ -202,31 +197,6 @@ public class LocationInfomationFragment extends Fragment implements LatLngListen
|
||||
mPoint = point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a location has been selected (non-Javadoc)
|
||||
*
|
||||
// * @see com.TwentyCodes.android.location.OnLocationSelectedListener#onLocationSelected(com.google.android.maps.GeoPoint)
|
||||
*/
|
||||
@Override
|
||||
public void onLocationSelected(final LatLng point) {
|
||||
if (point != null) {
|
||||
Log.d(TAG, "onLocationSelected() " + point.toString());
|
||||
|
||||
if (mRadiusOverlay != null)
|
||||
mRadiusOverlay.setLocation(point);
|
||||
|
||||
if (mMap != null)
|
||||
mMap.getMap().moveCamera(CameraUpdateFactory.newLatLng(point));
|
||||
|
||||
if (mListener != null) {
|
||||
final ContentValues info = new ContentValues();
|
||||
info.put(RingerDatabase.KEY_LOCATION, point.toString());
|
||||
mListener.onInfoContentChanged(info);
|
||||
}
|
||||
} else
|
||||
Log.d(TAG, "onLocationSelected() Location was null");
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -247,7 +217,7 @@ public class LocationInfomationFragment extends Fragment implements LatLngListen
|
||||
switch (seekBar.getId()) {
|
||||
case R.id.radius:
|
||||
mRadiusTextView.setText(GeoUtils.distanceToString(Float.valueOf(progress) / 1000, true));
|
||||
mRadiusOverlay.setRadius(progress);
|
||||
mCircle.setRadius(progress);
|
||||
//todo invalidate this shit
|
||||
// mMap.invalidate();
|
||||
if (mListener != null) {
|
||||
@@ -267,6 +237,7 @@ public class LocationInfomationFragment extends Fragment implements LatLngListen
|
||||
public void onResume() {
|
||||
if (mMapEditToggle.isChecked())
|
||||
mGPS.enableLocationUpdates(this);
|
||||
setUpMapIfNeeded();
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@@ -301,4 +272,84 @@ public class LocationInfomationFragment extends Fragment implements LatLngListen
|
||||
@Override
|
||||
public void onStopTrackingTouch(final SeekBar seekBar) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the map if it is possible to do so (i.e., the Google Play services APK is correctly
|
||||
* installed) and the map has not already been instantiated.. This will ensure that we only ever
|
||||
* call {@link #setUpMap()} once when {@link #mMap} is not null.
|
||||
* <p>
|
||||
* If it isn't installed {@link SupportMapFragment} (and
|
||||
* {@link com.google.android.gms.maps.MapView MapView}) will show a prompt for the user to
|
||||
* install/update the Google Play services APK on their device.
|
||||
* <p>
|
||||
* A user can return to this FragmentActivity after following the prompt and correctly
|
||||
* installing/updating/enabling the Google Play services. Since the FragmentActivity may not have been
|
||||
* completely destroyed during this process (it is likely that it would only be stopped or
|
||||
* paused), {@link #onCreate(Bundle)} may not be called again so we should call this method in
|
||||
* {@link #onResume()} to guarantee that it will be called.
|
||||
*/
|
||||
private void setUpMapIfNeeded() {
|
||||
// Do a null check to confirm that we have not already instantiated the map.
|
||||
if (mMap == null) {
|
||||
// Try to obtain the map from the SupportMapFragment.
|
||||
mMap = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
|
||||
// Check if we were successful in obtaining the map.
|
||||
if (mMap != null) {
|
||||
setUpMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is where we can add markers or lines, add listeners or move the camera.
|
||||
* This should only be called once and when we are sure that {@link #mMap} is not null.
|
||||
*/
|
||||
private void setUpMap() {
|
||||
|
||||
final CircleOptions circle = new CircleOptions();
|
||||
circle.strokeColor(Color.GREEN);
|
||||
circle.fillColor(Color.argb(100, 0, 255, 0));
|
||||
circle.center(new LatLng(0, 0));
|
||||
circle.radius(0);
|
||||
mCircle = mMap.addCircle(circle);
|
||||
|
||||
if (mCircle.getCenter() != null) {
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLng(mCircle.getCenter()));
|
||||
//todo zoom
|
||||
// mMap.setZoom(16);
|
||||
}
|
||||
|
||||
|
||||
// mMap.addCircle(mRadiusOverlay.getCircleOptions());
|
||||
|
||||
//
|
||||
// mMap.setDoubleTapZoonEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick(LatLng point) {
|
||||
if (point != null) {
|
||||
Log.d(TAG, "onLocationSelected() " + point.toString());
|
||||
|
||||
if (mCircle != null)
|
||||
mCircle.setCenter(point);
|
||||
|
||||
if (mMap != null)
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLng(point));
|
||||
|
||||
if (mListener != null) {
|
||||
final ContentValues info = new ContentValues();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(point.latitude).append(",").append(point.longitude);
|
||||
info.put(RingerDatabase.KEY_LOCATION, sb.toString());
|
||||
mListener.onInfoContentChanged(info);
|
||||
}
|
||||
} else
|
||||
Log.d(TAG, "onLocationSelected() Location was null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationSelected(LatLng point) {
|
||||
onMapClick(point);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user